Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B'A championship is held in Berland, in which n players participate. The player with the number i has a_i ( a_i ge 1 ) tokens. The championship consists of n-1 games, which are played according to the following rules: 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 n=4 , a = [1, 2, 4, 3] , then one of the options for the game (there could be other options) is: 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. The first line contains one integer t ( 1 <= t <= 10^4 ) -- the number of test cases. Then t test cases follow. The first line of each test case consists of one positive integer n ( 1 <= n <= 2 cdot 10^5 ) -- the number of players in the championship. The second line of each test case contains n positive integers a_1, a_2, ldots, a_n ( 1 <= a_i <= 10^9 ) -- the number of tokens the players have. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . 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. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
107623512 |
Gassa |
E |
Feb. 16, 2021, 5:08 p.m. |
OK |
D |
TESTS |
8 |
156 |
6144000 |
|
|
107624584 |
ruban |
E |
Feb. 16, 2021, 5:16 p.m. |
OK |
FPC |
TESTS |
8 |
607 |
158412800 |
|
|
remove filters
Back to search problems