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

17638번 - Separator 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.2 초 512 MB292220100.000%

문제

Let A = (a1, a2, . . .) be a sequence of distinct integers. An index j is called a separator if the following two conditions hold:

  • for all k < j: ak < aj,
  • for all k > j: ak > aj.

In other words, the array A consists of three parts: all elements smaller then aj, then aj itself, and finally all elements greater than aj.

For instance, let A = (30, 10, 20, 50, 80, 60, 90). The separators are the indices 4 and 7, corresponding to the values 50 and 90.

The sequence A is initially empty. You are given a sequence a1, . . . , an of elements to append to A, one after another. After appending each ai, output the current number si of separators in the sequence you have.

The input format is selected so that you have to compute the answers online. Instead of the elements ai you should append to A, you are given a sequence bi.

Process the input as follows:

The empty sequence A contains s0 = 0 separators.

For each i from 1 to n, inclusive:

  1. Calculate the value ai = (bi + si−1) mod 109.
  2. Append ai to the sequence A.
  3. Calculate si : the number of separators in the current sequence A.
  4. . Output a line containing the value si.

입력

The first line contains a single integer n (1 ≤ n ≤ 106): the number of queries to process.

Then, n lines follow. The i-th of these lines contains the integer bi (0 ≤ bi ≤ 109 − 1). The values bi are chosen in such a way that the values ai you’ll compute will all be distinct.

출력

As described above, output n lines with the values s1 through sn.

제한

서브태스크

번호배점제한
120

n ≤ 100

230

n ≤ 1000

340

n ≤ 100,000

410

No additional constraints.

예제 입력 1

7
30
9
20
50
79
58
89

예제 출력 1

1
0
0
1
2
1
2

예제 입력 2

10
0
0
0
0
0
0
0
0
0
0

예제 출력 2

1
2
3
4
5
6
7
8
9
10

힌트

The first example equals is described in the problem statement.

The second example is decoded as A = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9).

출처

Olympiad > Central European Olympiad in Informatics > CEOI 2019 > Practice 2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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