European Girls' Olympiad in Informatics: 2023 Day 2 Problem 2
In the ancient city of Ica, there is said to be a palace
with wealth beyond imagination. Inside, there is a corridor
with
The boxes of candy are numbered
As the guardian of the palace, you would like to move the boxes around so that boxes with a lot of candy end up closer to the entrance.
You are given the array
Input Specification
The first line of the input contains three integers,
The second line of the input contains
Output Specification
If it is impossible to achieve the objective using the
operations, print NO
.
Otherwise, print a single integer, the minimal number of operations.
Constraints and Scoring
. . . for .
Note: The numbers in the input may not fit in a
Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.
Group | Score | Limits |
---|---|---|
1 | 6 | |
2 | 19 | |
3 | 16 | |
4 | 30 | |
5 | 29 | No additional constraints |
Example
In the first sample test case, the first two elements should
sum to at least 10 20 4 6 3 3
, and indeed the first two elements sum to
In the second sample test case, the
In the third sample test case, it is impossible to make the
first two elements sum to at least
Sample Input 1
6 2 27
10 4 20 6 3 3
Sample Output 1
1
Sample Input 2
6 5 5000000000
1000000000 1000000000 0 1000000000 1000000000 1000000000
Sample Output 2
3
Sample Input 3
3 2 100
20 30 60
Sample Output 3
NO
Sample Input 4
1 1 100
100
Sample Output 4
0
Comments