/** kutbilim.one **/
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define int long long
#define endl '\n'
/*
ifstream in("test.txt");
#define cin in */
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
priority_queue< pair<int, int> > q;
vector<int> a(n);
for(int i = 0; i < n; i++){
cin >> a[i];
q.push({a[i], i+1});
}
vector< pair<int, vector<int>> > result;
while(true){
vector<int> val(k, 0), ind(k, 0);
for(int i = 0; i < k; i++){
val[i] = q.top().first;
ind[i] = q.top().second;
q.pop();
}
if(val[0] == 0) break;
int x = val.back();
if(x == 0) return cout << -1, 0;
result.push_back({x, ind});
for(int i = k-1; i >= 0; i--){
val[i] -= x;
q.push({val[i], ind[i]});
}
}
cout << result.size() << endl;
for(auto i : result){
cout << i.first << " ";
for(auto j : i.second) cout << j << " ";
cout << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
600 ms |
70332 KB |
n=1000000 |
2 |
Correct |
379 ms |
45140 KB |
n=666666 |
3 |
Correct |
207 ms |
26704 KB |
n=400000 |
4 |
Incorrect |
106 ms |
15312 KB |
Jury has the answer but participant has not |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |