#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];
vector<pair<int, int>> tab;
int main()
{
scanf("%d%d", &nbVerrous, &tailleOperation);
tab.resize(nbVerrous);
for (int indVerrou = 0; indVerrou < nbVerrous; ++indVerrou) {
scanf("%d", &reqUnlock[indVerrou]);
tab[indVerrou] = {reqUnlock[indVerrou], indVerrou};
}
sort(tab.begin(), tab.end());
reverse(tab.begin(), tab.end());
vector<vector<int>> operations;
operations.reserve(100*1000);
vector<int> curOp(tailleOperation);
while (! tab.empty()) {
while ((! tab.empty()) && cur[tab.back().second] == reqUnlock[tab.back().second]) {
tab.pop_back();
}
if (tab.empty()) {
break;
}
int nbRestants = tab.size();
if (nbRestants < tailleOperation) {
printf("-1\n");
return 0;
}
for (int indPris = 0; indPris < tailleOperation; ++indPris) {
curOp[indPris] = tab[nbRestants - indPris - 1].second;
++cur[curOp[indPris]];
}
operations.push_back(curOp);
}
printf("%d\n", (int)(operations.size()));
for (auto op : operations) {
printf("1 ");
for (int choisi : op) {
printf("%d ", choisi+1);
}
printf("\n");
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
456 KB |
n=4 |
2 |
Incorrect |
3 ms |
484 KB |
Jury has the answer but participant has not |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
456 KB |
n=4 |
2 |
Incorrect |
3 ms |
484 KB |
Jury has the answer but participant has not |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
456 KB |
n=4 |
2 |
Incorrect |
3 ms |
484 KB |
Jury has the answer but participant has not |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2070 ms |
525312 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
456 KB |
n=4 |
2 |
Incorrect |
3 ms |
484 KB |
Jury has the answer but participant has not |
3 |
Halted |
0 ms |
0 KB |
- |