2045: [USACO 2025 February Contest, Bronze] Problem 2. Making Mexes

文件提交:无需freopen 内存限制:256 MB 时间限制:8.000 S
评测方式:普通裁判 命题人:
提交:1 解决:1

题目描述

You are given an array  of  non-negative integers  (). In one operation, you can change any element of  to any non-negative integer.

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

输入

The first line contains .

The next line contains .

输出

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

样例输入

4
2 2 2 0

样例输出

1
0
3
1
2

提示

  • To make the mex of  equal to , we can change  to  (or any positive integer). In the resulting array,  is the smallest non-negative integer that the array does not contain, so  is the mex of the array.
  • To make the mex of  equal to , we don't need to make any changes since  is already the smallest non-negative integer that  does not contain.
  • To make the mex of  equal to , we need to change the first three elements of . For example, we can change  to be .

SCORING:

  • Inputs 2-6: 
  • Inputs 7-11: No additional constraints.

来源/分类