#P11542. Reliable Report Sorting
Reliable Report Sorting
Reliable Report Sorting
At Penguin High School, the administrative office faces challenges in managing a large number of student reports. Each report indicates the number of students entering (a positive integer) or leaving (a negative integer) the school. Initially, the school has students. The reports are considered reliable if and only if there exists an ordering of these reports such that the cumulative number of students never becomes negative at any point (i.e. the running total is always ). Your task is to determine whether the given set of reports is reliable.
Note: The reports are provided in an unordered fashion, and you are allowed to rearrange them arbitrarily to achieve the required condition.
inputFormat
The first line contains a single integer , the number of reports. The second line contains space-separated integers, where each integer represents a report. A positive integer signifies that many students entered the school, whereas a negative integer signifies that many students left the school.
outputFormat
Output a single line: "Yes" if the reports are reliable, and "No" otherwise.
sample
3
1 2 -3
Yes