Galactic Collegiate Programming Contest
Time limit5sMemory limit512 MB
After each of m solve events, report the rank of team 1 among n teams ranked by solve count and then penalty.
- Level
Medium6 of 10
- Topics
- Sorting, Binary search, Array, Implementation
- Solved
- No attempts yet
Problem
In 2117 the International Collegiate Programming Contest has grown a lot and it is now the Galactic Collegiate Programming Contest (GCPC).
This year teams take part. The teams are numbered , and your favorite team is team .
The score of a team is a pair of integers , where is the number of problems the team has solved and is its total penalty. Every solved problem carries a penalty, and the total penalty of a team is the sum of the penalties of the problems that team has solved. How a single penalty is computed does not matter in this problem.
Take two teams and with scores and . The score of is better than the score of if , or if and . The rank of a team is , where is the number of teams with a better score.
The organizers publish no scoreboard. They only send a message the moment some team solves a problem. Report the rank of team after every message.
Input
The first line contains two integers and (, ), the number of teams and the number of events.
Each of the next lines contains two integers and (, ), meaning that team has solved a problem with penalty . The events are given in the order in which they happen.
Output
Print lines. On line , print the rank of team after the first events have happened.