#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;
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 <PII> nums;
vector <vector <int> > ans;
for (int i = 1; i <= n; i++) {
int x; cin >> x;
nums.pb({x, i});
}
nums.pb({0, 0});
// int dbg = 0;
while(1) {
sort(LLA(nums));
if (nums[0].ff == 0) break;
int num = nums[0].ff, nx = nums[k-1].ff;
int cur = max(1, num - nx);
vector <int> curAns(1, cur);
for (int i = 0; i < k; i++) {
nums[i].ff-=cur;
curAns.pb(nums[i].ss);
}
ans.pb(curAns);
// printPII(nums);
// if (dbg++==10) break;
}
for (int i = 0; i < n; i++) {
if (nums[i].ff < 0) {
cout << "-1\n";
return 0;
}
}
cout << ans.size() << '\n';
for (auto el : ans) {
print(el);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
n=4 |
2 |
Correct |
0 ms |
204 KB |
n=3 |
3 |
Incorrect |
0 ms |
204 KB |
Taken too much stones from the heap |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
n=4 |
2 |
Correct |
0 ms |
204 KB |
n=3 |
3 |
Incorrect |
0 ms |
204 KB |
Taken too much stones from the heap |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
n=4 |
2 |
Correct |
0 ms |
204 KB |
n=3 |
3 |
Incorrect |
0 ms |
204 KB |
Taken too much stones from the heap |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2074 ms |
8564 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
n=4 |
2 |
Correct |
0 ms |
204 KB |
n=3 |
3 |
Incorrect |
0 ms |
204 KB |
Taken too much stones from the heap |
4 |
Halted |
0 ms |
0 KB |
- |