Submission #644135

# Submission time Handle Problem Language Result Execution time Memory
644135 2022-09-24T01:19:45 Z Do_you_copy Gift (IZhO18_nicegift) C++17
7 / 100
858 ms 87120 KB
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;
using ll = long long;
using pii = pair <int, int>;
#define pb push_back
const int maxN = 1e6 + 10;
const int maxOP = 3e6;
int n, k;
int a[maxN];
priority_queue <pii> PQ;

vector <vector <int>> e;
void Init(){
    cin >> n >> k;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
        PQ.push({a[i], i});
    }
    for (int i = 1; i * k <= maxOP; ++i){
        vector <int> pos;
        for (int j = 0; j < k; ++j){
            pos.pb(PQ.top().se);
            PQ.pop();
        }
        if (!a[pos.back()]) break;
        e.pb({a[pos.back()]});
        for (int j = 0; j < k; ++j){
            e.back().pb(pos[j]);
            a[pos[j]] -= a[pos.back()];
        }
        for (int j = 0; j < k; ++j){
            PQ.push({a[pos[j]], pos[j]});
        }
    }
    for (int i = 1; i <= n; ++i){
        if (a[i]){
            cout << -1; return;
        }
    }
    cout << e.size() << "\n";
    for (auto &i: e){
        for (auto &j: i) cout << j << " ";
        cout << "\n";
    }
}

signed main() {
    Init();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 212 KB n=4
6 Correct 1 ms 304 KB n=2
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 212 KB n=4
6 Correct 1 ms 304 KB n=2
7 Correct 1 ms 212 KB n=5
8 Correct 0 ms 212 KB n=8
9 Incorrect 1 ms 212 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 212 KB n=4
6 Correct 1 ms 304 KB n=2
7 Correct 1 ms 212 KB n=5
8 Correct 0 ms 212 KB n=8
9 Incorrect 1 ms 212 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 858 ms 87120 KB n=1000000
2 Correct 605 ms 48680 KB n=666666
3 Correct 351 ms 27552 KB n=400000
4 Incorrect 217 ms 15128 KB Jury has the answer but participant has not
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 212 KB n=4
6 Correct 1 ms 304 KB n=2
7 Correct 1 ms 212 KB n=5
8 Correct 0 ms 212 KB n=8
9 Incorrect 1 ms 212 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -