Task: | Turnaus |
Sender: | |
Submission time: | 2015-12-20 14:54:13 +0200 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 19 |
#2 | ACCEPTED | 42 |
#3 | ACCEPTED | 39 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.05 s | 1 | details |
#2 | ACCEPTED | 0.06 s | 1 | details |
#3 | ACCEPTED | 0.05 s | 1 | details |
#4 | ACCEPTED | 0.05 s | 1 | details |
#5 | ACCEPTED | 0.05 s | 1 | details |
#6 | ACCEPTED | 0.06 s | 2 | details |
#7 | ACCEPTED | 0.05 s | 2 | details |
#8 | ACCEPTED | 0.06 s | 2 | details |
#9 | ACCEPTED | 0.06 s | 2 | details |
#10 | ACCEPTED | 0.09 s | 2 | details |
#11 | ACCEPTED | 0.05 s | 3 | details |
#12 | ACCEPTED | 0.05 s | 3 | details |
#13 | ACCEPTED | 0.06 s | 3 | details |
#14 | ACCEPTED | 0.06 s | 3 | details |
#15 | ACCEPTED | 0.04 s | 3 | details |
#16 | ACCEPTED | 0.10 s | 3 | details |
#17 | ACCEPTED | 0.11 s | 3 | details |
#18 | ACCEPTED | 0.09 s | 3 | details |
#19 | ACCEPTED | 0.10 s | 3 | details |
#20 | ACCEPTED | 0.08 s | 3 | details |
Code
#include <iostream> #include <vector> #include <algorithm> #include <utility> #include <set> typedef long long LL; using namespace std; LL next_pow_2(LL n){ LL x = 1; while(x < n) x *= 2; return x; } int main(){ LL n; cin >> n; multiset<pair<LL,LL> > dudes; // needed games, dude id for(int i = 0; i < n; i++){ LL x; cin >> x; if(x != 0) dudes.insert({x,i+1}); } vector<pair<LL,LL> > games; while(true){ if(dudes.empty()) break; LL needed_1 = dudes.rbegin()->first; LL id_1 = dudes.rbegin()->second; dudes.erase(--dudes.end()); vector<pair<LL, LL> > opponents; // new needed, id for(LL i = 0; i < needed_1; i++){ if(dudes.empty()){ cout << "QAQ" << endl; return 0; } LL needed_2 = dudes.rbegin()->first; LL id_2 = dudes.rbegin()->second; dudes.erase(--dudes.end()); games.push_back({id_1,id_2}); if(needed_2 - 1 > 0) opponents.push_back({needed_2-1,id_2}); } for(auto p : opponents) dudes.insert(p); } cout << games.size() << "\n"; for(auto p : games) cout << p.first << " " << p.second << "\n"; }
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
10 5 4 2 6 6 3 4 7 8 5 |
correct output |
---|
25 9 8 9 5 9 4 9 10 ... |
user output |
---|
25 9 8 9 5 9 4 9 10 ... |
Test 2
Group: 1
Verdict: ACCEPTED
input |
---|
10 6 4 4 6 5 6 1 2 1 7 |
correct output |
---|
21 10 6 10 4 10 1 10 5 ... |
user output |
---|
21 10 6 10 4 10 1 10 5 ... |
Test 3
Group: 1
Verdict: ACCEPTED
input |
---|
10 3 5 3 2 3 1 1 1 1 6 |
correct output |
---|
13 10 2 10 5 10 3 10 1 ... |
user output |
---|
13 10 2 10 5 10 3 10 1 ... |
Test 4
Group: 1
Verdict: ACCEPTED
input |
---|
10 4 4 4 6 3 5 7 1 5 9 |
correct output |
---|
24 10 7 10 4 10 9 10 6 ... |
user output |
---|
24 10 7 10 4 10 9 10 6 ... |
Test 5
Group: 1
Verdict: ACCEPTED
input |
---|
10 5 8 5 5 8 4 0 1 4 0 |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 6
Group: 2
Verdict: ACCEPTED
input |
---|
100 57 62 69 61 64 62 56 58 61 58 ... |
correct output |
---|
2850 96 89 96 100 96 91 96 68 ... |
user output |
---|
2850 96 89 96 100 96 91 96 68 ... |
Test 7
Group: 2
Verdict: ACCEPTED
input |
---|
100 52 56 50 52 63 53 56 65 47 55 ... |
correct output |
---|
2813 97 100 97 77 97 75 97 89 ... |
user output |
---|
2813 97 100 97 77 97 75 97 89 ... |
Test 8
Group: 2
Verdict: ACCEPTED
input |
---|
100 52 58 46 54 55 51 48 49 53 45 ... |
correct output |
---|
2421 90 97 90 78 90 61 90 94 ... |
user output |
---|
2421 90 97 90 78 90 61 90 94 ... |
Test 9
Group: 2
Verdict: ACCEPTED
input |
---|
100 53 44 41 54 34 44 44 51 42 38 ... |
correct output |
---|
2145 99 87 99 88 99 93 99 82 ... |
user output |
---|
2145 99 87 99 88 99 93 99 82 ... |
Test 10
Group: 2
Verdict: ACCEPTED
input |
---|
100 51 2 34 17 16 53 56 37 11 94 4... |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 11
Group: 3
Verdict: ACCEPTED
input |
---|
100 49 55 47 49 57 47 59 52 51 52 ... |
correct output |
---|
2674 96 87 96 80 96 89 96 74 ... |
user output |
---|
2674 96 87 96 80 96 89 96 74 ... |
Test 12
Group: 3
Verdict: ACCEPTED
input |
---|
100 44 49 47 50 46 45 46 43 45 53 ... |
correct output |
---|
2361 100 96 100 88 100 99 100 81 ... |
user output |
---|
2361 100 96 100 88 100 99 100 81 ... |
Test 13
Group: 3
Verdict: ACCEPTED
input |
---|
100 55 50 46 47 48 54 59 51 50 43 ... |
correct output |
---|
2318 92 85 92 71 92 53 92 56 ... |
user output |
---|
2318 92 85 92 71 92 53 92 56 ... |
Test 14
Group: 3
Verdict: ACCEPTED
input |
---|
100 45 51 47 56 47 51 47 55 57 41 ... |
correct output |
---|
2464 87 84 87 89 87 73 87 88 ... |
user output |
---|
2464 87 84 87 89 87 73 87 88 ... |
Test 15
Group: 3
Verdict: ACCEPTED
input |
---|
100 40 95 88 91 27 5 93 69 46 50 7... |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 16
Group: 3
Verdict: ACCEPTED
input |
---|
100000 25 24 26 22 24 31 23 22 16 32 ... |
correct output |
---|
100000 15 10 15 14 15 6 15 12 ... |
user output |
---|
100000 15 10 15 14 15 6 15 12 ... |
Test 17
Group: 3
Verdict: ACCEPTED
input |
---|
100000 27 24 25 26 18 32 26 19 21 19 ... |
correct output |
---|
100000 6 66 6 37 6 16 6 62 ... |
user output |
---|
100000 6 66 6 37 6 16 6 62 ... |
Test 18
Group: 3
Verdict: ACCEPTED
input |
---|
100000 22 28 23 31 26 31 25 27 22 29 ... |
correct output |
---|
100000 16 12 16 6 16 4 16 30 ... |
user output |
---|
100000 16 12 16 6 16 4 16 30 ... |
Test 19
Group: 3
Verdict: ACCEPTED
input |
---|
100000 19 26 25 24 25 29 20 23 30 22 ... |
correct output |
---|
100000 9 27 9 6 9 207 9 156 ... |
user output |
---|
100000 9 27 9 6 9 207 9 156 ... |
Test 20
Group: 3
Verdict: ACCEPTED
input |
---|
100000 1 2 3 2 1 4 2 0 5 3 3 3 4 4 3 ... |
correct output |
---|
QAQ |
user output |
---|
QAQ |