QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#727268 | #3323. Coin Stacks | gambit# | AC ✓ | 0ms | 3856kb | C++17 | 803b | 2024-11-09 12:20:44 | 2024-11-09 12:20:51 |
Judging History
answer
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n; cin >> n; priority_queue<pi> pq;
vector<pi> dap;
for (int i = 1; i <= n; i++) {
int x; cin >> x;
if (x == 0) continue;
pq.push({x, i});
}
while (pq.size() >= 2) {
pi a = pq.top(); pq.pop();
pi b = pq.top(); pq.pop();
a.first--; b.first--;
dap.push_back({a.second, b.second});
if (a.first) pq.push(a);
if (b.first) pq.push(b);
}
if (pq.empty()) {
cout << "yes\n";
for (auto &x: dap) cout << x.first << ' ' << x.second << '\n';
} else cout << "no\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
2 1 1
output:
yes 2 1
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
2 1 2
output:
no
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
2 1 3
output:
no
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
2 2 2
output:
yes 2 1 2 1
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
2 2 3
output:
no
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
2 2 4
output:
no
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
2 0 0
output:
yes
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
2 0 1
output:
no
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
2 0 2
output:
no
result:
ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
3 1 4 6
output:
no
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
3 1 5 6
output:
yes 3 2 3 2 3 2 3 2 3 2 3 1
result:
ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
yes
result:
ok
Test #13:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
50 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
output:
yes 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
result:
ok
Test #14:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
output:
yes 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 50 49 48 47 46...
result:
ok
Test #15:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1000
output:
no
result:
ok
Test #16:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
50 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 951
output:
no
result:
ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
50 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 902
output:
no
result:
ok
Test #18:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
41 17 11 18 18 5 10 12 20 11 9 12 6 11 3 13 20 12 2 16 11 12 12 9 0 11 19 3 14 7 5 10 19 14 19 8 6 17 2 20 16 19
output:
no
result:
ok
Test #19:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
38 1 2 13 20 19 1 0 20 6 6 3 9 6 14 18 10 0 19 10 13 18 7 17 1 17 20 9 6 19 5 16 16 16 5 1 15 18 14
output:
yes 26 8 4 29 26 18 8 5 4 37 29 26 21 18 15 8 5 4 37 29 26 25 23 21 18 15 8 5 4 37 33 32 31 29 26 25 23 21 18 15 8 5 4 37 36 33 32 31 29 26 25 23 21 18 15 8 5 4 38 37 36 33 32 31 29 26 25 23 21 18 15 14 8 5 4 38 37 36 33 32 31 29 26 25 23 21 20 18 15 14 8 5 4 3 38 37 36 33 32 31 29 26 25 23 21 20 18...
result:
ok
Test #20:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
3 16 15 17
output:
yes 3 1 3 2 3 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1
result:
ok
Test #21:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
50 20 11 17 18 20 8 8 2 4 1 5 10 2 6 14 17 8 1 17 4 13 11 19 1 13 9 4 1 20 14 11 12 2 6 11 20 19 8 6 6 4 15 12 19 13 17 8 5 7 10
output:
no
result:
ok
Test #22:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
27 19 6 19 13 5 15 19 20 10 1 0 17 19 6 20 13 9 17 10 12 11 7 9 14 18 12 20
output:
no
result:
ok
Test #23:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
26 4 19 8 7 12 2 14 0 10 2 8 15 16 19 12 4 1 16 18 12 6 20 14 3 7 9
output:
yes 22 14 22 2 22 19 14 2 22 19 14 2 22 19 18 14 13 2 22 19 18 14 13 12 2 23 22 19 18 14 13 12 7 2 23 22 19 18 14 13 12 7 2 23 22 20 19 18 15 14 13 12 7 5 2 23 22 20 19 18 15 14 13 12 7 5 2 23 22 20 19 18 15 14 13 12 9 7 5 2 26 23 22 20 19 18 15 14 13 12 9 7 5 2 26 23 22 20 19 18 15 14 13 12 11 9 7 ...
result:
ok
Test #24:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
5 15 6 11 17 10
output:
no
result:
ok
Test #25:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
19 18 3 4 16 18 20 1 20 17 15 9 0 4 4 14 2 20 19 15
output:
no
result:
ok
Test #26:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
31 0 5 6 5 7 7 20 1 20 14 14 12 9 10 0 13 11 20 3 5 2 0 9 20 6 5 6 3 2 5 17
output:
no
result:
ok
Test #27:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
43 12 18 19 7 1 13 7 13 10 17 14 15 6 2 2 2 20 4 11 8 18 12 0 0 7 1 17 17 3 20 12 8 16 17 9 4 0 13 9 15 11 1 10
output:
no
result:
ok
Test #28:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
2 19 1
output:
no
result:
ok
Test #29:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
7 1 11 13 19 13 12 15
output:
yes 4 7 4 7 4 7 4 5 4 3 4 7 4 6 5 4 3 7 6 5 4 3 2 7 6 5 4 3 2 7 6 5 4 3 2 7 6 5 4 3 2 7 6 5 4 3 2 7 6 5 4 3 2 7 6 5 4 3 2 7 6 5 4 3 2 7 6 5 4 3 2 7 6 5 4 3 2 7 6 5 4 3 2 1
result:
ok
Test #30:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
13 0 15 5 6 2 13 6 2 17 20 16 5 13
output:
yes 10 9 10 11 10 9 10 11 10 9 10 2 11 10 9 2 13 11 10 9 6 2 13 11 10 9 6 2 13 11 10 9 6 2 13 11 10 9 6 2 13 11 10 9 6 2 13 11 10 9 6 2 13 11 10 9 6 2 13 11 10 9 7 6 4 2 13 12 11 10 9 7 6 4 3 2 13 12 11 10 9 7 6 4 3 2 13 12 11 10 9 7 6 4 3 2 13 12 11 10 9 8 7 6 5 4 3 2 13 12 11 10 9 8 7 6 5 4 3 2
result:
ok
Test #31:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
16 19 2 7 16 5 13 0 13 16 17 9 3 20 10 9 1
output:
yes 13 1 13 1 13 10 13 1 13 10 9 4 1 13 10 9 4 1 13 10 9 4 1 13 10 9 8 6 4 1 13 10 9 8 6 4 1 13 10 9 8 6 4 1 14 13 10 9 8 6 4 1 15 14 13 11 10 9 8 6 4 1 15 14 13 11 10 9 8 6 4 1 15 14 13 11 10 9 8 6 4 3 1 15 14 13 11 10 9 8 6 4 3 1 15 14 13 11 10 9 8 6 5 4 3 1 15 14 13 11 10 9 8 6 5 4 3 1 15 14 13 1...
result:
ok
Test #32:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
47 15 11 10 0 11 18 18 10 6 3 17 0 1 12 16 12 1 12 0 20 1 19 13 14 2 10 19 16 19 14 17 16 6 2 14 18 11 11 1 4 4 3 7 19 13 5 4
output:
no
result:
ok
Test #33:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
14 8 12 15 10 2 11 19 6 5 19 15 8 17 2
output:
no
result:
ok
Test #34:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
45 8 15 8 4 3 6 4 5 4 1 0 1 7 11 3 9 6 2 16 13 19 16 18 12 12 2 6 5 11 6 16 1 7 3 9 17 10 9 10 9 1 8 13 10 10
output:
yes 21 23 21 36 23 21 36 31 23 22 21 19 36 31 23 22 21 19 2 36 31 23 22 21 19 2 43 36 31 23 22 21 20 19 2 43 36 31 25 24 23 22 21 20 19 2 43 36 31 29 25 24 23 22 21 20 19 14 2 45 44 43 39 37 36 31 29 25 24 23 22 21 20 19 14 2 45 44 43 40 39 38 37 36 35 31 29 25 24 23 22 21 20 19 16 14 2 45 44 43 42 ...
result:
ok
Test #35:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
46 2 20 17 18 8 17 8 1 10 1 4 13 15 15 20 18 10 5 19 12 16 0 14 2 18 6 17 12 9 6 16 15 19 19 13 18 14 18 4 12 12 12 5 2 8 10
output:
yes 15 2 34 33 19 15 2 38 36 34 33 25 19 16 15 4 2 38 36 34 33 27 25 19 16 15 6 4 3 2 38 36 34 33 31 27 25 21 19 16 15 6 4 3 2 38 36 34 33 32 31 27 25 21 19 16 15 14 13 6 4 3 2 38 37 36 34 33 32 31 27 25 23 21 19 16 15 14 13 6 4 3 2 38 37 36 35 34 33 32 31 27 25 23 21 19 16 15 14 13 12 6 4 3 2 42 41...
result:
ok
Test #36:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
10 8 20 18 8 16 8 3 3 19 5
output:
yes 2 9 2 9 3 2 9 3 2 9 5 3 2 9 5 3 2 9 5 3 2 9 5 3 2 9 5 3 2 9 5 3 2 9 5 3 2 9 5 3 2 9 6 5 4 3 2 1 9 6 5 4 3 2 1 9 6 5 4 3 2 1 10 9 6 5 4 3 2 1 10 9 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1
result:
ok
Test #37:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
10 11 13 4 16 3 20 4 16 12 11
output:
yes 6 8 6 4 6 8 6 4 6 8 6 4 6 8 6 4 2 9 8 6 4 2 10 9 8 6 4 2 1 10 9 8 6 4 2 1 10 9 8 6 4 2 1 10 9 8 6 4 2 1 10 9 8 6 4 2 1 10 9 8 6 4 2 1 10 9 8 6 4 2 1 10 9 8 7 6 4 3 2 1 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1
result:
ok
Test #38:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
50 11 11 10 11 11 11 11 11 11 11 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 500 10 10 10 10 10 10 10 10 10 10 10 10 10 11 10
output:
yes 35 49 35 10 35 9 35 8 35 7 35 6 35 5 35 4 35 2 35 1 35 50 35 49 35 48 35 47 35 46 35 45 35 44 35 43 35 42 35 41 35 40 35 39 35 38 35 37 35 36 35 34 35 33 35 32 35 31 35 30 35 29 35 28 35 27 35 26 35 25 35 24 35 23 35 22 35 21 35 20 35 19 35 18 35 17 35 16 35 15 35 14 35 13 35 12 35 11 35 10 35 9...
result:
ok