欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1490E.Accidental Victory
Accidental Victory
A championship is held in Berland, in which players participate. The player with the number has () tokens.
The championship consists of games, which are played according to the following rules:
- in each game, two random players with non-zero tokens are selected;
- the player with more tokens is considered the winner of the game (in case of a tie, the winner is chosen randomly);
- the winning player takes all of the loser's tokens;
The last player with non-zero tokens is the winner of the championship.
All random decisions that are made during the championship are made equally probable and independently.
For example, if , , then one of the options for the game (there could be other options) is:
- during the first game, the first and fourth players were selected. The fourth player has more tokens, so he takes the first player's tokens. Now ;
- during the second game, the fourth and third players were selected. They have the same number of tokens, but in a random way, the third player is the winner. Now ;
- during the third game, the second and third players were selected. The third player has more tokens, so he takes the second player's tokens. Now ;
- the third player is declared the winner of the championship.
Championship winners will receive personalized prizes. Therefore, the judges want to know in advance which players have a chance of winning, i.e have a non-zero probability of winning the championship. You have been asked to find all such players.
Input
The first line contains one integer () — the number of test cases. Then test cases follow.
The first line of each test case consists of one positive integer () — the number of players in the championship.
The second line of each test case contains positive integers () — the number of tokens the players have.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, print the number of players who have a nonzero probability of winning the championship. On the next line print the numbers of these players in increasing order. Players are numbered starting from one in the order in which they appear in the input.
Samples
2
4
1 2 4 3
5
1 1 1 1 1
3
2 3 4
5
1 2 3 4 5
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |