#include<bits/stdc++.h>
using namespace std;
const int N = (int)1e6+7;
int n, k, a[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
long long tot = 0;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
tot += a[i];
}
sort(a+1, a+1+n);
if(tot%k) {
cout << "-1\n";
return 0;
}
if(a[n]>tot/2) {
cout << "-1\n";
return 0;
}
cout << tot/k << "\n";
set<pair<int, int> > s;
for(int i = 1; i <= n; ++i) {
s.insert({a[i], i});
}
for(int i = 1; i <= tot/k; ++i) {
vector<int> cur;
for(int j = 0; j < k; ++j) {
auto it = s.begin();
cur.push_back(it->second);
s.erase(it);
}
cout << "1 ";
for(auto id : cur) {
assert(a[id]>0);
cout << id << ' ';
}
cout << "\n";
for(auto id : cur) {
a[id]--;
if(a[id]>0) {
s.insert({a[id], id});
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
4188 KB |
Jury has the answer but participant has not |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |