545D. Queue
greedy, implementation, sortings, 1300, https://codeforces.com/problemset/problem/545/D
Little girl Susie went shopping with her mom and she wondered how to improve service quality.
There are n people in the queue. For each person we know time
Help Susie find out what is the maximum number of not disappointed people can be achieved by swapping people in the queue.
Input
The first line contains integer
The next line contains n integers
Output
Print a single number — the maximum number of not disappointed people in the queue.
Examples
input
5
15 2 1 5 3output
4Note
Value 4 is achieved at such an arrangement, for example: 1, 2, 3, 5, 15. Thus, you can make everything feel not disappointed except for the person with time 5.
n=int(input())
t=[int(i) for i in input().split()]
t.sort()
wait=0
ans=0
for i in range(n):
if t[i]>=wait:
wait+=t[i]
ans+=1
print(ans)