# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495218 | Nalrimet | Gift (IZhO18_nicegift) | C++17 | 2037 ms | 524292 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int inf = 1000000000;
#define F first
#define S second
#define pb push_back
priority_queue<pair<int, int>> q;
int n, k, a[N];
vector<int> v;
vector<vector<int>> ans;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
for(int i = 1; i <= n; ++i){
cin >> a[i];
q.push({a[i], i});
}
while(!q.empty()){
if(q.size() < k){
cout << -1;
exit(0);
}
for(int i = 1; i <= k; ++i){
v.push_back(q.top().S);
q.pop();
}
ans.pb(v);
for(int i = 0; i < k; ++i){
a[v[i]]--;
if(a[v[i]] != 0) q.push({a[v[i]], v[i]});
}
v.clear();
}
cout << ans.size() << '\n';
for(auto to : ans){
cout << 1 << ' ';
for(auto to1 : to){
cout << to1 << ' ';
}
cout << '\n';
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |