Problem Sort
This problem just required 1 thing, that's implementation... this is what I had thought earlier and this took me 1 hour to understand that I was wrong with what I had to output in this Problem Statement, instead of just printing the Problem Indices, I took this to a different level and also found the Ranks of the Problems in 2 different ways, well, the problem seemed easy to the brim at last when I got my error but I just couldn't understand how I misunderstood the Statement.
When you pass all the Test Cases in the first submission ;)
Well, go for the Problem on your own first and see if you get it in the first go, if you do...you are awesome!
Problem Statement:-
Chef is organising a contest with problems (numbered through ). Each problem has subtasks (numbered through ).
The difficulty of a problem can be calculated as follows:
- Let's denote the score of the -th subtask of this problem by and the number of contestants who solved it by .
- Consider the subtasks sorted in the order of increasing score.
- Calculate the number of valid indices such that .
- For problem , the difficulty is a pair of integers .
You should sort the problems in the increasing order of difficulty levels. Since difficulty level is a pair, problem is more difficult than problem if the number is greater for problem than for problem , or if and is the same for problems and .
Input
- The first line of the input contains two space-separated integers and denoting the number of problems and the number of subtasks in each problem.
- lines follow. For each valid , the -th of these lines contains space-separated integers denoting the scores of the -th problem's subtasks, and the -th of these lines contains space-separated integers denoting the number of contestants who solved the -th problem's subtasks.
Output
Print lines containing one integer each — the indices of the problems in the increasing order of difficulty.
Constraints
- for each valid
- for each valid
- in each problem, the scores of all subtasks are unique
Subtasks
Subtask #1 (25 points):
Subtask #2 (75 points): original constraints
Sample 1:
3 3 16 24 60 498 861 589 14 24 62 72 557 819 16 15 69 435 779 232
Code Implementation:-
Explanation:-
So, this problem is just requiring you to have the implementation skills, firstly the input is a little bit tricky but you can do that if you are confident in the language that you are using. Secondly you just have to sort the problems on the basis of their scores and then get the count k, that tells the Difficulty level of a problem, if this count k is less then that means that the problem is difficult , so the difficulty of the problem will depend on this count k. Now, we just have to sort the problems on the basis of this count k and then get the indices( 1 based indexing here, don't confuse indices with the 0 based indices ) and output them in order. Like if there are 3 problems and the 1st Problem has the count as 1, 2nd Problem as 0 and 3rd Problem as 2, this means that the most easy problem is Problem 2 so output 2, then comes Problem 1 so output that and the lastly 3rd Problem so output 3.
Comments
Post a Comment