답안 #608805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
608805 2022-07-27T10:18:11 Z pakhomovee Gift (IZhO18_nicegift) C++17
30 / 100
349 ms 78592 KB
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#include <set>
#include <numeric>
#include <queue>

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int& i : a) cin >> i;
    vector<int> b(n, 0);
    priority_queue<pair<int, int>> q;
    vector<pair<int, vector<int>>> act;
    for (int i = 0; i < n; ++i) q.push({ a[i], i });
    while (q.size() >= k) {
        vector<int> pos;
        for (int j = 0; j < k; ++j) {
            pos.push_back(q.top().second);
            q.pop();
        }
        for (int i : pos) {
            ++b[i];
            if (b[i] < a[i]) {
                q.push({ a[i] - b[i], i });
            }
        }
        act.push_back({ 1, pos });
    }
    if (q.empty()) {
        cout << act.size() << '\n';
        for (pair<int, vector<int>> x : act) {
            cout << x.first << ' ';
            for (int j : x.second) {
                cout << j + 1 << ' ';
            }
            cout << '\n';
        }
    } else {
        cout << -1;
    }
}

Compilation message

nicegift.cpp: In function 'int32_t main()':
nicegift.cpp:23:21: warning: comparison of integer expressions of different signedness: 'std::priority_queue<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |     while (q.size() >= k) {
      |            ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 1 ms 340 KB n=3
3 Correct 0 ms 320 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 212 KB n=4
6 Correct 0 ms 212 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 1 ms 340 KB n=3
3 Correct 0 ms 320 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 212 KB n=4
6 Correct 0 ms 212 KB n=2
7 Correct 0 ms 212 KB n=5
8 Correct 2 ms 1108 KB n=8
9 Correct 7 ms 1340 KB n=14
10 Correct 4 ms 1048 KB n=11
11 Correct 31 ms 5048 KB n=50000
12 Correct 30 ms 4992 KB n=50000
13 Correct 21 ms 3784 KB n=10
14 Correct 23 ms 3480 KB n=685
15 Correct 26 ms 3648 KB n=623
16 Correct 14 ms 2120 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 1 ms 340 KB n=3
3 Correct 0 ms 320 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 212 KB n=4
6 Correct 0 ms 212 KB n=2
7 Correct 0 ms 212 KB n=5
8 Correct 2 ms 1108 KB n=8
9 Correct 7 ms 1340 KB n=14
10 Correct 4 ms 1048 KB n=11
11 Correct 31 ms 5048 KB n=50000
12 Correct 30 ms 4992 KB n=50000
13 Correct 21 ms 3784 KB n=10
14 Correct 23 ms 3480 KB n=685
15 Correct 26 ms 3648 KB n=623
16 Correct 14 ms 2120 KB n=973
17 Correct 23 ms 2756 KB n=989
18 Correct 11 ms 1084 KB n=563
19 Correct 17 ms 1232 KB n=592
20 Correct 18 ms 1360 KB n=938
21 Correct 14 ms 1104 KB n=747
22 Correct 19 ms 1220 KB n=991
# 결과 실행 시간 메모리 Grader output
1 Incorrect 349 ms 78592 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 1 ms 340 KB n=3
3 Correct 0 ms 320 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 212 KB n=4
6 Correct 0 ms 212 KB n=2
7 Correct 0 ms 212 KB n=5
8 Correct 2 ms 1108 KB n=8
9 Correct 7 ms 1340 KB n=14
10 Correct 4 ms 1048 KB n=11
11 Correct 31 ms 5048 KB n=50000
12 Correct 30 ms 4992 KB n=50000
13 Correct 21 ms 3784 KB n=10
14 Correct 23 ms 3480 KB n=685
15 Correct 26 ms 3648 KB n=623
16 Correct 14 ms 2120 KB n=973
17 Correct 23 ms 2756 KB n=989
18 Correct 11 ms 1084 KB n=563
19 Correct 17 ms 1232 KB n=592
20 Correct 18 ms 1360 KB n=938
21 Correct 14 ms 1104 KB n=747
22 Correct 19 ms 1220 KB n=991
23 Incorrect 349 ms 78592 KB Jury has the answer but participant has not
24 Halted 0 ms 0 KB -