QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 512 MB Puntuación total: 100 Hackeable ✓

#3997. 糖果机

Estadísticas

JB 非常喜欢糖果。

有一天,他发现了一台装有 $N$ 颗糖果的糖果机。在阅读了机器的说明书后,他知道自己可以选择这 $N$ 颗糖果的一个子集。每颗糖果都有一个甜度值。在 JB 选择完子集后,假设所选糖果的平均甜度值为 $X$,那么所有甜度值严格大于 $X$ 的糖果都将归 JB 所有。在 JB 做出选择后,机器就会消失,因此 JB 只有一次做出选择的机会。

JB 并不关心糖果有多甜,他只想通过做出选择来最大化他能得到的糖果数量。JB 已经被糖果迷住了,无法思考,所以他需要你的帮助。

输入格式

第一行包含一个整数 $N$ ($1 \le N \le 10^6$),表示机器中糖果的数量。 第二行包含 $N$ 个整数 $a_1, a_2, \dots, a_N$ ($1 \le a_i \le 10^9$),表示糖果的甜度值。

输出格式

一个整数,表示 JB 能得到的最大糖果数量。

样例

输入 1

5
1 2 3 4 5

输出 1

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.