포럼
문제 ICPC00248

G. Galactic Collegiate Programming Contest

설명

One hundred years from now, in \(2117\), the International Collegiate Programming Contest (of which the NCPC is a part) has expanded significantly and it is now the Galactic Collegiate Programming Contest (GCPC).

This year there are \(n\) teams in the contest. The teams are numbered \(1,2,\ldots,n\), and your favorite team has number \(1\).

Like today, the score of a team is a pair of integers \((a,b)\) where \(a\) is the number of solved problems and \(b\) is the total penalty of that team. When a team solves a problem there is some associated penalty (not necessarily calculated in the same way as in the NCPC – the precise details are not important in this problem). The total penalty of a team is the sum of the penalties for the solved problems of the team.

Consider two teams \(t_1\) and \(t_2\) whose scores are \((a_1,b_1)\) and \((a_2,b_2)\). The score of team \(t_1\) is better than that of \(t_2\) if either \(a_1>a_2\), or if \(a_1=a_2\) and \(b_1. The rank of a team is \(k+1\) where \(k\) is the number of teams whose score is better.

You would like to follow the performance of your favorite team. Unfortunately, the organizers of GCPC do not provide a scoreboard. Instead, they send a message immediately whenever a team solves a problem.

제약
입력 형식

The first line of input contains two integers \(n\) and \(m\), where \(1 \le n \le 10^5\) is the number of teams, and \(1 \le m \le 10^5\) is the number of events.

Then follow \(m\) lines that describe the events. Each line contains two integers \(t\) and \(p\) (\(1 \le t \le n\) and \(1 \le p \le 1000\)), meaning that team \(t\) has solved a problem with penalty \(p\). The events are ordered by the time when they happen.

출력 형식

Output \(m\) lines. On the \(i\)'th line, output the rank of your favorite team after the first \(i\) events have happened.

예제 1
입력
3 4
2 7
3 5
1 6
1 9
출력
2
3
2
1
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NCPC 2017

평가 및 의견

G. Galactic Collegiate Programming Contest

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

G. Galactic Collegiate Programming Contest

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8