시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB229842.105%

문제

There are some animals with distinct strength levels getting water from a watering hole. The more animals that are at the watering hole the less water each animal will get. For this reason some of the animals will try to force the others to leave.

Periodically the weakest animal in the group may be attacked by some of the stronger animals. Other animals may come to the aid of the weakest animal. The weakest animal will leave if the sum of the strength levels of the attackers is strictly greater than the sum of the strength levels of the defenders. The other defenders, if any, will remain. This may repeat any number of times.

As an up-and-coming zoologist, you are interested in determining if animals are logical thinkers. You have a lot of data, so you will write a program to help check if, in each situation, the animals behaved optimally. Each animal wants to eliminate as many other animals as possible without being eliminated itself.

Given the strength level of each animal and assuming each animal always makes the best decision for their best interests, determine how many animals are guaranteed to remain after all aggression has been resolved.

입력

The first line of input contains a single integer $n$ ($1 \le n \le 5 \times 10^5$), which is the number of animals.

Each of the next $n$ lines contains a single integer $s$ ($1 \le s \le 10^9$). These are the strengths of the animals. No two strengths will be the same.

출력

Output a single integer, which is the number of animals guaranteed to remain.

예제 입력 1

4
3
4
8
9

예제 출력 1

3

예제 입력 2

8
20
1
2
13
9
5
8
61

예제 출력 2

1

출처

ICPC > Regionals > North America > North America Qualification Contest > ICPC North America Qualifier 2022 A번

  • 문제를 만든 사람: Travis Meade