Problem - E - Codeforces
Problem - E - Codeforces
|
QuanVanHoang | Logout
HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN
A subarray is defined as a sequence of one or more consecutive elements of the array. You need
to split the array a into k non-overlapping subarrays b1 , b2 , … , bk such that the union of these
subarrays equals the entire array. Additionally, you need to maximize the value of x , which is → Submit?
equal to the minimum MEX(bi ) , for i ∈ [1..k] .
Language: GNU G++20 13.2 (64 bit, wi
MEX(v) denotes the smallest non-negative integer that is not present in the array v.
Choose
Chọn tệp Không có …được chọn
file:
Input
The first line contains an integer t
4
(1 ≤ t ≤ 10 ) — the number of test cases. Submit
5
It is guaranteed that the sum of n across all test cases does not exceed 2 ⋅ 10 .
Output
For each query, output a single number — the maximum value x such that there exists a partition
of the array a into k subarrays where the minimum MEX equals x .
Example
input Copy
7
1 1
0
5 1
0 1 3 2 4
6 2
2 1 0 0 1 2
5 5
0 0 0 0 0
5 2
2 3 4 5 6
6 2
0 0 1 1 2 2
4 4
1 0 0 0
output Copy
1
5
3
1
0
1
0