RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00656

Dizalo

Unrated 레이팅 미적용
난이도
3s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

In one city there is a tall skyscraper with \(n\) floors. There are \(n\) people waiting
for an elevator on the ground floor. The \(i-th\) person wants to go to the floor \(a@@RISE_MATH_BLOCK_0@@i\)
were not \(in\) the elevator, how many exits would there \(be\) then?
Mirko is interested in an answer before Slavko’s first question and after every question. Note that for each
question, all the people from previous questions are also not considered to be in the elevator.
Mirko started solving the problem but soon realized that even for him, this would not be quite easy. Help
him solve this problem!
Note: The elevator will always move from the first floor to the \(n-th\) floor and stop at every floor on which
someone wants to exit.

제약

Subtask 1 (16 points): n, \(q \le 100\)

Subtask 2 (19 points): n, \(q \le 1\,000\)

Subtask 3 (29 points): \(q = 0\)

Subtask 4 (46 points): No additional constraints.

입력 형식

The first line contains two n\(on-ne\)gative integers \(n\) and \(q\) (\(0 \le q < n \le 10^{5}\)), the number of peop\(le/fl\)oors
and the number of questions.
The second line contains \(n\) integers \(a@@RISE_MATH_BLOCK_0@@i \le n\), a\(i\)̸ = \(a@@RISE_MATH_BLOCK_1@@i\) is the floor on which
the \(i-th\) person wants to exit the elevator. The sequence (\(a@@RISE_MATH_BLOCK_2@@i\) (\(1 \le x@@RISE_MATH_BLOCK_3@@j\) for each \(i\)̸ = \(j\)), Slavko’s questions.

출력 형식

In one line, print \(q + 1\) numbers, where the \(i-th\) is the number of exists after \(i - 1\) questions.

서브태스크
서브태스크점수설명

1

16점

n, \(q \le 100\)

2

19점

n, \(q \le 1\,000\)

3

29점

\(q = 0\)

4

46점

No additional constraints.

예제 1
입력
5 2
3 4 1 2 5
3 2
출력
9 6 4
예제 2
입력
7 0
4 5 2 1 6 3 7
출력
13
예제 3
입력
3 2
3 1 2
1 2
출력
5 2 1
설명

Clarification of the first example:
The illustration shows the exits from the elevator before the first query.
The elevator is on the first floor, and the person at position 3 wants to
exit. But, for them to exit, persons at positions 1 and 2 must exit first,
and they return to the elevator at the same positions.
After that, on the second floor, the person at position 4 wants to exit.
Again, persons at positions 1 and 2 must exit first, and they return to
the elevator at the same positions.
After that, on the third floor, the person at position 1 exits the elevator,
without anyone else having to exit the elevator.
After that, on the fourth floor, the person at position 2 exits the elevator,
without anyone else having to exit the elevator.
And finally, on the fifth floor, the person at position 5 exits the elevator.
In total, there were 3 + 3 + 1 + 1 + 1 = 9 exits from the elevator.

문제 정보

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

출처 COCI 2023/2024 Contest 2

평가 및 의견

Dizalo

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

Log in to rate problems.

개별 의견

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

풀이 제출

Dizalo

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