# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
511072 |
2022-01-15T05:28:06 Z |
Mazaalai |
Gift (IZhO18_nicegift) |
C++17 |
|
1176 ms |
8636 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;
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);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
n=4 |
2 |
Correct |
0 ms |
204 KB |
n=3 |
3 |
Incorrect |
0 ms |
316 KB |
Taken too much stones from the heap |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
n=4 |
2 |
Correct |
0 ms |
204 KB |
n=3 |
3 |
Incorrect |
0 ms |
316 KB |
Taken too much stones from the heap |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
n=4 |
2 |
Correct |
0 ms |
204 KB |
n=3 |
3 |
Incorrect |
0 ms |
316 KB |
Taken too much stones from the heap |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1176 ms |
8636 KB |
Not all heaps are empty in the end |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
n=4 |
2 |
Correct |
0 ms |
204 KB |
n=3 |
3 |
Incorrect |
0 ms |
316 KB |
Taken too much stones from the heap |
4 |
Halted |
0 ms |
0 KB |
- |