Submission #57404

# Submission time Handle Problem Language Result Execution time Memory
57404 2018-07-14T21:42:41 Z hugo_pm Gift (IZhO18_nicegift) C++14
30 / 100
854 ms 62272 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];
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
1 Correct 3 ms 504 KB n=4
2 Correct 3 ms 624 KB n=3
3 Correct 3 ms 624 KB n=3
4 Correct 2 ms 628 KB n=4
5 Correct 2 ms 716 KB n=4
6 Correct 2 ms 852 KB n=2
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB n=4
2 Correct 3 ms 624 KB n=3
3 Correct 3 ms 624 KB n=3
4 Correct 2 ms 628 KB n=4
5 Correct 2 ms 716 KB n=4
6 Correct 2 ms 852 KB n=2
7 Correct 3 ms 852 KB n=5
8 Correct 5 ms 1308 KB n=8
9 Correct 15 ms 1696 KB n=14
10 Correct 10 ms 1696 KB n=11
11 Correct 61 ms 4956 KB n=50000
12 Correct 49 ms 5200 KB n=50000
13 Correct 37 ms 5200 KB n=10
14 Correct 53 ms 5200 KB n=685
15 Correct 65 ms 5200 KB n=623
16 Correct 23 ms 5200 KB n=973
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB n=4
2 Correct 3 ms 624 KB n=3
3 Correct 3 ms 624 KB n=3
4 Correct 2 ms 628 KB n=4
5 Correct 2 ms 716 KB n=4
6 Correct 2 ms 852 KB n=2
7 Correct 3 ms 852 KB n=5
8 Correct 5 ms 1308 KB n=8
9 Correct 15 ms 1696 KB n=14
10 Correct 10 ms 1696 KB n=11
11 Correct 61 ms 4956 KB n=50000
12 Correct 49 ms 5200 KB n=50000
13 Correct 37 ms 5200 KB n=10
14 Correct 53 ms 5200 KB n=685
15 Correct 65 ms 5200 KB n=623
16 Correct 23 ms 5200 KB n=973
17 Correct 46 ms 5200 KB n=989
18 Correct 16 ms 5200 KB n=563
19 Correct 23 ms 5200 KB n=592
20 Correct 22 ms 5200 KB n=938
21 Correct 17 ms 5200 KB n=747
22 Correct 18 ms 5200 KB n=991
# Verdict Execution time Memory Grader output
1 Incorrect 854 ms 62272 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB n=4
2 Correct 3 ms 624 KB n=3
3 Correct 3 ms 624 KB n=3
4 Correct 2 ms 628 KB n=4
5 Correct 2 ms 716 KB n=4
6 Correct 2 ms 852 KB n=2
7 Correct 3 ms 852 KB n=5
8 Correct 5 ms 1308 KB n=8
9 Correct 15 ms 1696 KB n=14
10 Correct 10 ms 1696 KB n=11
11 Correct 61 ms 4956 KB n=50000
12 Correct 49 ms 5200 KB n=50000
13 Correct 37 ms 5200 KB n=10
14 Correct 53 ms 5200 KB n=685
15 Correct 65 ms 5200 KB n=623
16 Correct 23 ms 5200 KB n=973
17 Correct 46 ms 5200 KB n=989
18 Correct 16 ms 5200 KB n=563
19 Correct 23 ms 5200 KB n=592
20 Correct 22 ms 5200 KB n=938
21 Correct 17 ms 5200 KB n=747
22 Correct 18 ms 5200 KB n=991
23 Incorrect 854 ms 62272 KB Not all heaps are empty in the end
24 Halted 0 ms 0 KB -