# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
511078 |
2022-01-15T05:38:41 Z |
Mazaalai |
Gift (IZhO18_nicegift) |
C++17 |
|
2000 ms |
211348 KB |
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define LLA(x) x.rbegin(),x.rend()
#define print(x) for(auto el:x)cout<<el<<' ';cout<<"\n";
#define printPII(x) for(auto [a,b]:x)cout<<a<<","<<b<<' ';cout<<'\n';
using namespace std;
using PII = pair <int, int>;
int n, k;
bool impossible;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
cin >> n >> k;
vector <vector <int> > ans;
set <PII> bfs;
for (int i = 1; i <= n; i++) {
int x; cin >> x;
bfs.insert({x, i});
}
while(1) {
auto it = bfs.rbegin();
PII x = *it;
bfs.erase(bfs.lower_bound(x));
auto it1 = bfs.rbegin();
PII y = *it1;
bfs.erase(bfs.lower_bound(y));
if (x.ff <= 0 && y.ff <= 0) break;
ans.pb({1, x.ss, y.ss});
x.ff--, y.ff--;
if (x.ff < 0 || y.ff < 0) impossible = 1;
bfs.insert(x);
bfs.insert(y);
}
// int dbg = 0;
if (impossible) {
cout << "-1\n";
return 0;
}
cout << ans.size() << '\n';
for (auto el : ans) {
print(el);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
312 KB |
n=4 |
2 |
Correct |
1 ms |
312 KB |
n=3 |
3 |
Correct |
0 ms |
204 KB |
n=3 |
4 |
Correct |
1 ms |
204 KB |
n=4 |
5 |
Correct |
1 ms |
204 KB |
n=4 |
6 |
Correct |
0 ms |
204 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
312 KB |
n=4 |
2 |
Correct |
1 ms |
312 KB |
n=3 |
3 |
Correct |
0 ms |
204 KB |
n=3 |
4 |
Correct |
1 ms |
204 KB |
n=4 |
5 |
Correct |
1 ms |
204 KB |
n=4 |
6 |
Correct |
0 ms |
204 KB |
n=2 |
7 |
Correct |
1 ms |
292 KB |
n=5 |
8 |
Correct |
12 ms |
3456 KB |
n=8 |
9 |
Correct |
8 ms |
1160 KB |
n=14 |
10 |
Correct |
6 ms |
972 KB |
n=11 |
11 |
Correct |
59 ms |
6148 KB |
n=50000 |
12 |
Correct |
54 ms |
6160 KB |
n=50000 |
13 |
Correct |
23 ms |
3404 KB |
n=10 |
14 |
Correct |
26 ms |
3008 KB |
n=685 |
15 |
Correct |
28 ms |
3324 KB |
n=623 |
16 |
Correct |
23 ms |
1924 KB |
n=973 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
312 KB |
n=4 |
2 |
Correct |
1 ms |
312 KB |
n=3 |
3 |
Correct |
0 ms |
204 KB |
n=3 |
4 |
Correct |
1 ms |
204 KB |
n=4 |
5 |
Correct |
1 ms |
204 KB |
n=4 |
6 |
Correct |
0 ms |
204 KB |
n=2 |
7 |
Correct |
1 ms |
292 KB |
n=5 |
8 |
Correct |
12 ms |
3456 KB |
n=8 |
9 |
Correct |
8 ms |
1160 KB |
n=14 |
10 |
Correct |
6 ms |
972 KB |
n=11 |
11 |
Correct |
59 ms |
6148 KB |
n=50000 |
12 |
Correct |
54 ms |
6160 KB |
n=50000 |
13 |
Correct |
23 ms |
3404 KB |
n=10 |
14 |
Correct |
26 ms |
3008 KB |
n=685 |
15 |
Correct |
28 ms |
3324 KB |
n=623 |
16 |
Correct |
23 ms |
1924 KB |
n=973 |
17 |
Incorrect |
29 ms |
3400 KB |
Taken too much stones from the heap |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2101 ms |
211348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
312 KB |
n=4 |
2 |
Correct |
1 ms |
312 KB |
n=3 |
3 |
Correct |
0 ms |
204 KB |
n=3 |
4 |
Correct |
1 ms |
204 KB |
n=4 |
5 |
Correct |
1 ms |
204 KB |
n=4 |
6 |
Correct |
0 ms |
204 KB |
n=2 |
7 |
Correct |
1 ms |
292 KB |
n=5 |
8 |
Correct |
12 ms |
3456 KB |
n=8 |
9 |
Correct |
8 ms |
1160 KB |
n=14 |
10 |
Correct |
6 ms |
972 KB |
n=11 |
11 |
Correct |
59 ms |
6148 KB |
n=50000 |
12 |
Correct |
54 ms |
6160 KB |
n=50000 |
13 |
Correct |
23 ms |
3404 KB |
n=10 |
14 |
Correct |
26 ms |
3008 KB |
n=685 |
15 |
Correct |
28 ms |
3324 KB |
n=623 |
16 |
Correct |
23 ms |
1924 KB |
n=973 |
17 |
Incorrect |
29 ms |
3400 KB |
Taken too much stones from the heap |
18 |
Halted |
0 ms |
0 KB |
- |