# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
608802 | pakhomovee | Gift (IZhO18_nicegift) | C++17 | 402 ms | 78720 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 <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int& i : a) cin >> i;
vector<int> b(n, 0);
priority_queue<pair<int, int>> q;
vector<pair<int, vector<int>>> act;
for (int i = 0; i < n; ++i) q.push({ a[i], i });
while (q.size() >= k) {
vector<int> pos;
for (int j = 0; j < k; ++j) {
pos.push_back(q.top().second);
q.pop();
}
for (int i : pos) {
++b[i];
if (b[i] < a[i]) {
q.push({ a[i] - b[i], i });
}
}
act.push_back({ 1, pos });
}
if (q.empty()) {
for (pair<int, vector<int>> x : act) {
cout << x.first << ' ';
for (int j : x.second) {
cout << j + 1 << ' ';
}
cout << '\n';
}
} else {
cout << -1;
}
}
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... |