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

33736번 - Making Mexes 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB96706273.810%

문제

You are given an array $a$ of $N$ non-negative integers $a_1, a_2, \dots, a_N$ (1ドル\le N\le 2\cdot 10^5, 0\le a_i\le N$). In one operation, you can change any element of $a$ to any non-negative integer.

The mex of an array is the minimum non-negative integer that it does not contain. For each $i$ in the range 0ドル$ to $N$ inclusive, compute the minimum number of operations you need in order to make the mex of $a$ equal $i$.

입력

The first line contains $N$.

The next line contains $a_1,a_2,\dots, a_N$.

출력

For each $i$ in the range 0ドル$ to $N,ドル output the minimum number of operations for $i$ on a new line. Note that it is always possible to make the mex of $a$ equal to any $i$ in the range 0ドル$ to $N$.

제한

예제 입력 1

4
2 2 2 0

예제 출력 1

1
0
3
1
2
  • To make the mex of $a$ equal to 0ドル,ドル we can change $a_4$ to 3ドル$ (or any positive integer). In the resulting array, $[2, 2, 2, 3],ドル 0ドル$ is the smallest non-negative integer that the array does not contain, so 0ドル$ is the mex of the array.
  • To make the mex of $a$ equal to 1ドル,ドル we don't need to make any changes since 1ドル$ is already the smallest non-negative integer that $a = [2, 2, 2, 0]$ does not contain.
  • To make the mex of $a$ equal to 2ドル,ドル we need to change the first three elements of $a$. For example, we can change $a$ to be $[3, 1, 1, 0]$.

힌트

출처

Olympiad > USA Computing Olympiad > 2024-2025 Season > USACO 2025 February Contest > Bronze 2번

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

출처

대학교 대회

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

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