Programming Contest Cup
Time limit1sMemory limit512 MB
Given every contestant's scores from the first n-1 contests, find the worst rank you can end up at if you skip the last contest and others play it optimally against you.
- Level
Medium6 of 10
- Topics
- Greedy, Sorting, Simulation
- Solved
- No attempts yet
Problem
You are taking part in a programming contest cup. The cup consists of a series of programming contests, followed by a final at the end of the season for the 15 top ranked contestants in the cup. Only one contest is left before the final. You want to know whether your results so far have already secured a spot in the final. If they have, you may skip the last contest.
The cup ranking works as follows. In each contest, a contestant earns between 0 and 101 points. The aggregate score is the sum of the four highest scores the contestant achieved. For example, if a contestant got 45, 15, 32, 0, 30, and 20 points over 6 contests, the aggregate score is 45 + 32 + 30 + 20 = 127. The rank of a contestant X is 1 plus the number of contestants whose aggregate score is strictly larger than X's.
Points in a contest depend on the rank achieved, according to the table below. A rank worse than 30 earns 0 points.
If contestants share a rank, each of them receives the average points of the tied ranks, rounded up to the nearest integer. For example, if three contestants tie for second place, each receives points, and the next contestant has rank 5 and receives 45 points (or fewer, if 5th place is also tied). The same rule applies at rank 30. If 4711 contestants tie for 30th place, each of them receives 1 point.
A contestant may take part in each contest either on-site or online. An on-site participant gets 1 extra point, regardless of the original points. A contestant who does not take part in a contest gets 0 points.
Input
The first line contains two integers and (, ), where is the number of contests in the cup excluding the final, and is the number of people who took part in at least one of the first contests.
The next lines each describe one contestant with integers , where is the score that contestant received in the -th contest. The first contestant listed is you.
The point values in the input may not match actual contest points.
Output
Print a single integer , the worst possible rank you might end up in after the last contest, assuming you do not take part in it.