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

Making Mexes

Silver I 실버 I
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

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\).

Problem credits: Benjamin Qi

제약

SCORING

  • Inputs 2-6: \(N\le 10^3\)
  • Inputs 7-11: No additional constraints.

Problem credits: Benjamin Qi

입력 형식

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
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]\).
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2024-2025 > February > Bronze

태그

평가 및 의견

Making Mexes

개요
출제자 난이도 Silver I 실버 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Making Mexes

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