Codeforces 545D - Queue

Xem dạng PDF

Gửi bài giải

Điểm: 2,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 512M
Input: stdin
Output: stdout

Nguồn bài:
https://atcoder.jp/contests/abc116/tasks/abc116_d
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

Reference: Codeforces 545D — Queue

There are ~n~ people waiting to be served. The service time required by the ~i~-th person is ~t_i~.

You may rearrange the people in any order before the service begins.

The waiting time of a person is the total service time of all people placed before that person. A person is satisfied when their waiting time is not greater than their own service time. Otherwise, the person becomes disappointed.

Find the maximum possible number of satisfied people.

Input

  • The first line contains one integer ~n~.
  • The second line contains ~n~ integers: ~t_1, t_2, \ldots, t_n~.

Output

  • Print one integer: the maximum number of people who can remain satisfied.

Constraints

  • ~1 \le n \le 10^5~
  • ~1 \le t_i \le 10^9~

Example 1

Input:

5
15 2 1 5 3

Output:

4

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.