Logo
(追記) (追記ここまで)

30945번 - Attendance 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초 (추가 시간 없음) 128 MB144360.000%

문제

An ambitious university student has enrolled in just about every possible course. Unfortunately, the courses require mandatory attendance. He has decided to visit the university campus where the lectures are held several times a day. He will join every lecture that is running at that moment, sign the attendance sheet, and immediately leave the campus due to other obligations. He will return later that day, when he will repeat this process to sign attendance sheets at other lectures and so on until his name is on attendance sheets of all lectures.

As if this was not problematic enough, the student faces another obstacle: the schedule of the lectures keeps changing. Some lectures are added and some are canceled. The student has to keep adjusting his visiting schedule of the university to sign attendance sheets at all lectures.

Write a program that will start with an empty schedule of lectures and read sequential modifications, which are either an addition or removal of a single lecture. For every modification, output the minimum number of visits that the student has to make to sign attendance sheets at all lectures that are currently on the schedule.

입력

The first line contains the number of modifications $N,ドル which are given in the following $N$ lines. An addition of a lecture is described with two space-separated integers $A_i$ and $B_i,ドル which represent a lecture that is running from $A_i$ to $B_i$ (including both bounds). The lectures are numbered as they are added, sequentially from 1ドル$ onwards. A negative number $X_i$ represents a removal of lecture with the number $,円{-X_i}$.

출력

For every modification output a single line with the minimum number of required visits for the current schedule of lectures.

제한

  • 1ドル \leq N \leq 300,000円$
  • 0ドル \leq A_i \leq B_i \leq 10^9$
  • Every number of the lecture for removal $X_i$ will be valid – it will exist in the schedule at that moment.
  • Note the memory limit.

예제 입력 1

12
2 2
17 26
-2
12 21
0 0
19 21
16 22
14 20
15 19
13 14
-4
13 17

예제 출력 1

1
2
1
2
3
3
3
3
3
4
3
3

힌트

The first lecture to be added is $[2, 2]$ and is given number 1ドル$. Next added lecture is $[17, 26]$ with number 2ドル$. It is removed immediately afterwards, which is indicated by $-2$ in the input. The following added lecture is $[12, 21],ドル which is given number 3ドル$ and so on.

출처

ICPC > Regionals > Europe > Central European Regional Contest > CERC 2023 A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /