# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334711 | nikatamliani | Gift (IZhO18_nicegift) | C++14 | 2071 ms | 159368 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 = 2e5+10;
#define ll long long
int main() {
int n, k;
cin >> n >> k;
set<pair<int,int>> s;
for(int i = 1; i <= n; ++i) {
int x;
cin >> x;
s.insert({-x, i});
}
vector<vector<pair<int,int>>> answer;
while(s.begin()->first < 0) {
vector<pair<int,int>> v;
for(pair<int,int> p : s) {
v.push_back(p);
if(v.size() == k) break;
}
for(pair<int,int> p : v) {
s.erase(p);
p.first++;
if(p.first > 0) {
cout << "-1\n";
return 0;
}
s.insert(p);
}
answer.push_back(v);
}
cout << answer.size() << '\n';
for(auto v : answer) {
for(pair<int,int> p : v) {
cout << p.second << ' ';
}
cout << "1\n";
}
}
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... |