logo AlgoBeat OnlineJudge
登录 注册

#215500. [NOISG 2026 Prelim] Hungry Cats

内存限制:1024 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

In the kingdom of cannibalistic cats, Ket the cat has just been informed that National Cat Day (NCD) will be held tomorrow. As the appointed software engineer, he is tasked with developing a system to report on the cannibalism situation.

There are cats joining the NCD celebration, numbered from 1 to . The -th cat has a happiness level of . At any point in time, a cat may eat a strictly less happy cat. After this happens, the happier cat’s happiness level increases by and it is no longer able to eat any other cats. In addition, the less happy cat vanishes.

Ket is tasked with determining whether it is possible for only one cat to be left at the end of the celebration. This means that all other cats were eaten.

输入格式

Your program must read from standard input.

The first line of input contains an integer .

The second line of input contains space-separated integers .

输出格式

Your program must print to standard output.

Output YES if it is possible for only one cat to be left after the celebration, or NO otherwise.

样例

样例输入 1

2
3141 59

样例输出 1

YES

样例输入 2

3
31 41 59

样例输出 2

YES

样例输入 3

5
10 0 24 25 10

样例输出 3

NO

样例输入 4

6
2 25 11 5 20 26

样例输出 4

NO

数据范围与提示

Sample Test Case 2 Explanation

There are cats with hunger levels , , and . It is possible for one cat to be left after the celebration if the second cat eats the first cat and subsequently gets eaten by the third cat.

Sample Test Case 3 Explanation

It is impossible for the cats to eat each other in a way that leaves one cat remaining at the end of the celebration.

Subtasks

For all test cases, the input will satisfy the following bounds:

  • for all

Your program will be tested on input instances that satisfy the following restrictions:

Subtask Score Additional Constraints
0 Sample test cases
1 8
2 10
3 6
4 18
5 28 is non-decreasing ( for all )
6 30 No additional constraints