# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
173868 |
2020-01-05T16:13:15 Z |
VEGAnn |
Gift (IZhO18_nicegift) |
C++14 |
|
41 ms |
10488 KB |
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pii pair<int, int>
#define ft first
#define sd second
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
const int oo = 2e9;
const ll OO = 1e18;
const int N = 100100;
set<pii, greater<pii> > st;
vector<vector<int> > ans;
vector<int> vc;
int n, k, a[N], sm;
void BAD(){
cout << -1;
exit(0);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> k;
for (int i = 0; i < n; i++){
cin >> a[i];
sm += a[i];
st.insert(MP(a[i], i));
}
while (sm > 0){
vc.clear();
for (int it = 0; it < k; it++){
pii cr = (*st.begin());
st.erase(st.begin());
if (cr.ft == 0)
BAD();
a[cr.sd]--;
sm--;
vc.PB(cr.sd);
}
ans.PB(vc);
for (int x : vc)
st.insert(MP(a[x], x));
}
cout << sz(ans) << '\n';
for (int it = 0; it < sz(ans); it++){
for (int x : ans[it])
cout << x + 1 << " ";
cout << "1\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
41 ms |
10488 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |