PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000086. Dãy đặc biệt với đúng x phần tử đủ lớn (Special Array With X Elements Greater Than or Equal X)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Dãy đặc biệt với đúng x phần tử đủ lớn (Special Array With X Elements Greater Than or Equal X)
Special Array With X Elements Greater Than or Equal X
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Given nonnegative integers, find a nonnegative integer for which exactly elements are at least . The value need not appear in the array. Output if none exists; a valid is unique.
Input
The first line contains ; the second line contains the values.
Output
Print if the array is special, otherwise -1.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
5
0 4 3 0 4
Output
3
Explanation
For , exactly three values () are at least . Thus meets the condition and is the unique answer.