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

Make All Distinct

Bronze II 브론즈 II
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

You have an integer array \(a_1\dots a_N\) with elements initially in the range
\([1,N]\)
(\(1\le N\le 2\cdot 10^5\)), as well as a nonzero integer \(K\)
(\(-N \le K\le N, K\neq 0\)).

You may perform the following operation as many times as you'd like (possibly
zero): select an index \(i\) and set \(a_i=a_i+K\).

Find the minimum number of operations to make all array elements distinct.

Problem credits: Akshaj Arora, Benjamin Qi

제약

SCORING

  • Inputs 2-4: \(N\le 50\)
  • Inputs 5-7: \(N\le 2000\)
  • Inputs 8-10: \(K=1\)
  • Inputs 11-13: No additional constraints.

Problem credits: Akshaj Arora, Benjamin Qi

입력 형식

The input consists of \(T\) (\(1\le T\le 10\)) independent tests. Each test is
described as follows:

The first line contains \(N\) and \(K\).

The second line contains \(a_1\dots a_N\).

It is guaranteed that the sum of \(N\) over all tests does not exceed
\(10^6\).

출력 형식

For each test, output a single line containing the minimum number of operations.

Note: The large size of integers involved in this problem may require the use
of 64-bit integer data types (e.g., a "long long" in C/C++).

예제 1
입력
4
4 1
4 1 4 1
4 -3
4 1 4 1
4 4
4 1 4 1
3 -1
1 1 2
출력
2
4
2
1
설명

For the first test, here is a possible sequence of two operations that makes all
elements distinct.

4 1 4 1
5 1 4 1 (a_1 += 1)
5 1 4 2 (a_4 += 1)
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2025-2026 > Third Contest > Bronze

태그

평가 및 의견

Make All Distinct

개요
출제자 난이도 Bronze II 브론즈 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Make All Distinct

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