답안 #57407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57407 2018-07-14T22:25:39 Z hugo_pm Gift (IZhO18_nicegift) C++14
30 / 100
880 ms 48120 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 2 ms 568 KB n=3
3 Correct 3 ms 568 KB n=3
4 Correct 3 ms 568 KB n=4
5 Correct 2 ms 640 KB n=4
6 Correct 2 ms 640 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 2 ms 568 KB n=3
3 Correct 3 ms 568 KB n=3
4 Correct 3 ms 568 KB n=4
5 Correct 2 ms 640 KB n=4
6 Correct 2 ms 640 KB n=2
7 Correct 3 ms 708 KB n=5
8 Correct 5 ms 1100 KB n=8
9 Correct 16 ms 1572 KB n=14
10 Correct 10 ms 1572 KB n=11
11 Correct 82 ms 4588 KB n=50000
12 Correct 57 ms 4588 KB n=50000
13 Correct 61 ms 4588 KB n=10
14 Correct 38 ms 4588 KB n=685
15 Correct 44 ms 4588 KB n=623
16 Correct 23 ms 4588 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 2 ms 568 KB n=3
3 Correct 3 ms 568 KB n=3
4 Correct 3 ms 568 KB n=4
5 Correct 2 ms 640 KB n=4
6 Correct 2 ms 640 KB n=2
7 Correct 3 ms 708 KB n=5
8 Correct 5 ms 1100 KB n=8
9 Correct 16 ms 1572 KB n=14
10 Correct 10 ms 1572 KB n=11
11 Correct 82 ms 4588 KB n=50000
12 Correct 57 ms 4588 KB n=50000
13 Correct 61 ms 4588 KB n=10
14 Correct 38 ms 4588 KB n=685
15 Correct 44 ms 4588 KB n=623
16 Correct 23 ms 4588 KB n=973
17 Correct 51 ms 4588 KB n=989
18 Correct 24 ms 4588 KB n=563
19 Correct 25 ms 4588 KB n=592
20 Correct 27 ms 4588 KB n=938
21 Correct 30 ms 4588 KB n=747
22 Correct 20 ms 4588 KB n=991
# 결과 실행 시간 메모리 Grader output
1 Incorrect 880 ms 48120 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 2 ms 568 KB n=3
3 Correct 3 ms 568 KB n=3
4 Correct 3 ms 568 KB n=4
5 Correct 2 ms 640 KB n=4
6 Correct 2 ms 640 KB n=2
7 Correct 3 ms 708 KB n=5
8 Correct 5 ms 1100 KB n=8
9 Correct 16 ms 1572 KB n=14
10 Correct 10 ms 1572 KB n=11
11 Correct 82 ms 4588 KB n=50000
12 Correct 57 ms 4588 KB n=50000
13 Correct 61 ms 4588 KB n=10
14 Correct 38 ms 4588 KB n=685
15 Correct 44 ms 4588 KB n=623
16 Correct 23 ms 4588 KB n=973
17 Correct 51 ms 4588 KB n=989
18 Correct 24 ms 4588 KB n=563
19 Correct 25 ms 4588 KB n=592
20 Correct 27 ms 4588 KB n=938
21 Correct 30 ms 4588 KB n=747
22 Correct 20 ms 4588 KB n=991
23 Incorrect 880 ms 48120 KB Not all heaps are empty in the end
24 Halted 0 ms 0 KB -