Cake Promise
Time limit2sMemory limit2048 MB
Given each team's per-problem solve times (X for unsolved), count the teams that solved more problems than Professor Wright, or the same number with an equal or lower total time.
- Level
Easy2 of 10
- Topics
- Implementation, Array
- Solved
- No attempts yet
Problem
Today is the big day. Professor P. Wright is organizing a programming contest. All of his students are participating, because he has promised to bake a cake for every team that can beat him in the contest.1 After the contest ends, Professor Wright receives a raw copy of the scoreboard, in which the teams are out of order. He is short on time, since besides baking he also has some exams to grade. He needs a program that calculates how many teams beat him in the contest.
The contest has a given number of problems, which the teams must solve as fast as possible. One team beats another if the first team has solved strictly more problems. If two teams have solved the same number of problems, the team with the lower total time beats the other. Professor Wright also bakes a cake for every team that solved the same number of problems and had the same total time as he did.
1 All characters and events in this problem statement are fictional. Any resemblance to actual lecturers is purely coincidental.
Input
The first line contains two integers and (), the number of teams and the number of programming problems. Professor Wright counts as one of the teams. Then lines follow, each containing values with the results of one team. The first of these lines gives the results of Professor Wright. Each value is either "X", meaning the team did not solve that problem, or an integer (), the number of minutes the team needed to solve it.
Output
Output the number of teams for which Professor Wright needs to bake a cake.