답안 #844068

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844068 2023-09-05T06:13:37 Z GrandTiger1729 Gift (IZhO18_nicegift) C++17
30 / 100
329 ms 66828 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int n, K; cin >> n >> K;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    priority_queue<pair<int, int>> pq;
    for (int i = 0; i < n; i++)
        pq.emplace(a[i], i);
    vector<vector<int>> ans;
    while (pq.size())
    {
        vector<pair<int, int>> res;
        for (int i = 0; i < K; i++)
        {
            if (pq.empty())
            {
                cout << -1 << '\n';
                return 0;
            }
            auto x = pq.top();
            pq.pop();
            x.first--;
            res.push_back(x);
        }
        ans.emplace_back();
        for (int i = 0; i < K; i++)
        {
            ans.back().push_back(res[i].second);
            if (res[i].first > 0)
                pq.push(res[i]);
        }
    }
    cout << ans.size() << '\n';
    for (auto &vec : ans)
    {
        cout << 1 << ' ';
        for (int j = 0; j < K; j++)
            cout << vec[j] + 1 << " \n"[j == K - 1];
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n=4
2 Correct 0 ms 348 KB n=3
3 Correct 1 ms 348 KB n=3
4 Correct 0 ms 348 KB n=4
5 Correct 1 ms 504 KB n=4
6 Correct 0 ms 348 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n=4
2 Correct 0 ms 348 KB n=3
3 Correct 1 ms 348 KB n=3
4 Correct 0 ms 348 KB n=4
5 Correct 1 ms 504 KB n=4
6 Correct 0 ms 348 KB n=2
7 Correct 0 ms 344 KB n=5
8 Correct 2 ms 920 KB n=8
9 Correct 5 ms 1176 KB n=14
10 Correct 3 ms 1116 KB n=11
11 Correct 25 ms 4436 KB n=50000
12 Correct 25 ms 4364 KB n=50000
13 Correct 17 ms 3344 KB n=10
14 Correct 19 ms 3088 KB n=685
15 Correct 26 ms 3332 KB n=623
16 Correct 12 ms 2068 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n=4
2 Correct 0 ms 348 KB n=3
3 Correct 1 ms 348 KB n=3
4 Correct 0 ms 348 KB n=4
5 Correct 1 ms 504 KB n=4
6 Correct 0 ms 348 KB n=2
7 Correct 0 ms 344 KB n=5
8 Correct 2 ms 920 KB n=8
9 Correct 5 ms 1176 KB n=14
10 Correct 3 ms 1116 KB n=11
11 Correct 25 ms 4436 KB n=50000
12 Correct 25 ms 4364 KB n=50000
13 Correct 17 ms 3344 KB n=10
14 Correct 19 ms 3088 KB n=685
15 Correct 26 ms 3332 KB n=623
16 Correct 12 ms 2068 KB n=973
17 Correct 20 ms 2568 KB n=989
18 Correct 9 ms 1116 KB n=563
19 Correct 14 ms 1564 KB n=592
20 Correct 19 ms 1464 KB n=938
21 Correct 12 ms 1372 KB n=747
22 Correct 13 ms 1372 KB n=991
# 결과 실행 시간 메모리 Grader output
1 Incorrect 329 ms 66828 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n=4
2 Correct 0 ms 348 KB n=3
3 Correct 1 ms 348 KB n=3
4 Correct 0 ms 348 KB n=4
5 Correct 1 ms 504 KB n=4
6 Correct 0 ms 348 KB n=2
7 Correct 0 ms 344 KB n=5
8 Correct 2 ms 920 KB n=8
9 Correct 5 ms 1176 KB n=14
10 Correct 3 ms 1116 KB n=11
11 Correct 25 ms 4436 KB n=50000
12 Correct 25 ms 4364 KB n=50000
13 Correct 17 ms 3344 KB n=10
14 Correct 19 ms 3088 KB n=685
15 Correct 26 ms 3332 KB n=623
16 Correct 12 ms 2068 KB n=973
17 Correct 20 ms 2568 KB n=989
18 Correct 9 ms 1116 KB n=563
19 Correct 14 ms 1564 KB n=592
20 Correct 19 ms 1464 KB n=938
21 Correct 12 ms 1372 KB n=747
22 Correct 13 ms 1372 KB n=991
23 Incorrect 329 ms 66828 KB Jury has the answer but participant has not
24 Halted 0 ms 0 KB -