이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
using namespace std;
const int maxVerrous = 1000*1000;
int nbVerrous, tailleOperation;
int reqUnlock[maxVerrous];
int cur[maxVerrous];
priority_queue<pair<int, int>> prq;
int main()
{
scanf("%d%d", &nbVerrous, &tailleOperation);
for (int indVerrou = 0; indVerrou < nbVerrous; ++indVerrou) {
scanf("%d", &reqUnlock[indVerrou]);
prq.push({reqUnlock[indVerrou], indVerrou});
}
vector<vector<int>> operations;
operations.reserve(100*1000);
vector<int> curOp(tailleOperation);
while (! prq.empty()) {
int nbRestants = prq.size();
if (nbRestants < tailleOperation) {
printf("-1\n");
return 0;
}
stack<pair<int, int>> remise;
for (int indPris = 0; indPris < tailleOperation; ++indPris) {
auto e = prq.top();
prq.pop();
curOp[indPris] = e.second;
if (e.first > 1) {
remise.push({e.first - 1, e.second});
}
}
operations.push_back(curOp);
while (! remise.empty()) {
prq.push(remise.top());
remise.pop();
}
}
printf("%d\n", (int)(operations.size()));
for (auto op : operations) {
printf("1 ");
for (int choisi : op) {
printf("%d ", choisi+1);
}
printf("\n");
}
return 0;
}
# | 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... |