CF545D.Queue

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 t__i needed to serve him. A person will be disappointed if the time he waits is more than the time needed to serve him. The time a person waits is the total time when all the people who stand in the queue in front of him are served. Susie thought that if we swap some people in the queue, then we can decrease the number of people who are disappointed.

Help Susie find out what is the maximum number of not disappointed people can be achieved by swapping people in the queue.

小女孩苏西和妈妈一起去购物,她开始思考如何提升服务质量。

队列中有 nn 个人。对每个人 ii,我们知道服务他所需的时间 tit_i。如果一个人的等待时间超过服务他所需的时间,则该人会感到失望。一个人的等待时间等于排在他前面的所有人被服务所花费的总时间。苏西认为,如果我们交换队列中某些人的位置,就有可能减少感到失望的人数。

请帮助苏西找出:通过重新排列队列中的人,最多能让多少人不感到失望。

输入格式

The first line contains integer n (1 ≤ n ≤ 105).

The next line contains n integers t__i (1 ≤ t__i ≤ 109), separated by spaces.

第一行包含一个整数 nn(1 ≤ n ≤ 1051 \leq n \leq 10^5)。

下一行包含 nn 个整数 tit_i(1 ≤ ti ≤ 1091 \leq t_i \leq 10^9),以空格分隔。

输出格式

Print a single number — the maximum number of not disappointed people in the queue.

输出一个数字——队列中未感到失望的人的最大数量。

输入输出样例

  • 输入#1

    5
    15 2 1 5 3

    输出#1

    4

说明/提示

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.

值 4 可通过如下排列实现,例如:1, 2, 3, 5, 15。因此,除了用时为 5 的人之外,其余所有人都不会感到失望。

输入解题思路,AI测评打分。不知道怎么写?

首页