답안 #57403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57403 2018-07-14T21:37:42 Z hugo_pm Gift (IZhO18_nicegift) C++14
0 / 100
2000 ms 525312 KB
#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 376 KB n=4
2 Execution timed out 2064 ms 525312 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Execution timed out 2064 ms 525312 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Execution timed out 2064 ms 525312 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2064 ms 525312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Execution timed out 2064 ms 525312 KB Time limit exceeded
3 Halted 0 ms 0 KB -