QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 32 MB مجموع النقاط: 100

#16939. 选举

الإحصائيات

Byteland 的公民最近在议会选举中进行了投票。现在,选举结果已经公布,各政党需要决定组成联合政府。

每个政党在议会中获得了一定数量的席位。联合政府必须是政党的一个子集,使得他们拥有的席位总数严格大于议会总席位的一半。联合政府希望拥有尽可能多的席位,以确保即使在少数成员缺席议会会议时,他们仍能通过提议的法律。

如果一个联合政府中的某个政党可以被移除,且剩余的政党拥有的席位总数仍然严格大于议会总席位的一半,则称该联合政府是冗余的。显然,这样一个可以被移除的政党实际上没有任何权力——无论其意见如何,联合政府的其他成员都能够强行通过法律。

你需要编写一个程序:

  • 从标准输入读取选举结果;
  • 寻找一个拥有最大可能议会席位数的非冗余联合政府;
  • 将该联合政府的描述写入标准输出。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 300$) —— 参加选举的政党数量。政党从 $1$ 到 $n$ 编号。

第二行包含 $n$ 个非负整数 $a_1, \dots, a_n$,用单个空格分隔,其中 $a_i$ 是第 $i$ 个政党获得的席位。你可以认为议会的总席位数是正数,且小于或等于 $100\,000$。

此外,在占总分 40% 的测试用例中,政党数量不超过 20。

输出格式

第一行应该包含一个整数 $k$ —— 拥有最大席位数的非冗余联合政府中的政党数量。

第二行应该包含 $k$ 个互不相同的整数,用单个空格分隔 —— 组成该联合政府的政党编号。

如果存在多个拥有最大席位数的非冗余联合政府,你可以输出其中任意一个。成员政党可以按任意顺序输出。

样例

输入样例 1

4
1 3 2 4

输出样例 1

2
2 4

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.