Submission #153965

# Submission time Handle Problem Language Result Execution time Memory
153965 2019-09-17T15:20:35 Z theboatman Gift (IZhO18_nicegift) C++17
7 / 100
1080 ms 85412 KB
#include <bits/stdc++.h>

#define y1 theboatman
#define make_struct(args...) {args}

#define int long long

using namespace std;

void sub_task2(int n, int k, vector <int> &a) {
    set <pair <int, int> > s;
    for(int i = 0; i < n; i++) {
        s.insert(make_pair(-a[i], i));
    }

    vector <vector <int> > ans;
    while(s.size()) {
        auto it = *s.begin();
        s.erase(it);

        if (!s.size()) {
            cout << "-1\n";
            exit(0);
        }

        auto it1 = *s.begin();
        s.erase(it1);

        vector <int> way;

        way.push_back(-it1.first);
        way.push_back(it.second + 1);
        way.push_back(it1.second + 1);

        ans.push_back(way);

        if (it.first - it1.first < 0) {
            s.insert(make_pair(it.first - it1.first, it.second));
        }

    }

    cout << ans.size() << "\n";
    for(auto it : ans) {
        for(auto i : it) {
            cout << i << " ";
        }
        cout << "\n";
    }
}

int32_t main() {
    cin.tie(0);
    ios :: sync_with_stdio(0);

    int n, k;
    cin >> n >> k;

    vector <int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    if (k == 2) {
        sub_task2(n, k, a);
    }
    else {
        cout << "kek\n";
    }
    return 0;
}
/*
2 3 3 4 6
*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB n=4
2 Correct 2 ms 376 KB n=3
3 Correct 2 ms 376 KB n=3
4 Correct 2 ms 376 KB n=4
5 Correct 2 ms 376 KB n=4
6 Correct 2 ms 376 KB n=2
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB n=4
2 Correct 2 ms 376 KB n=3
3 Correct 2 ms 376 KB n=3
4 Correct 2 ms 376 KB n=4
5 Correct 2 ms 376 KB n=4
6 Correct 2 ms 376 KB n=2
7 Correct 2 ms 376 KB n=5
8 Correct 2 ms 296 KB n=8
9 Incorrect 2 ms 376 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB n=4
2 Correct 2 ms 376 KB n=3
3 Correct 2 ms 376 KB n=3
4 Correct 2 ms 376 KB n=4
5 Correct 2 ms 376 KB n=4
6 Correct 2 ms 376 KB n=2
7 Correct 2 ms 376 KB n=5
8 Correct 2 ms 296 KB n=8
9 Incorrect 2 ms 376 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1080 ms 85412 KB n=1000000
2 Incorrect 152 ms 14692 KB Expected integer, but "kek" found
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB n=4
2 Correct 2 ms 376 KB n=3
3 Correct 2 ms 376 KB n=3
4 Correct 2 ms 376 KB n=4
5 Correct 2 ms 376 KB n=4
6 Correct 2 ms 376 KB n=2
7 Correct 2 ms 376 KB n=5
8 Correct 2 ms 296 KB n=8
9 Incorrect 2 ms 376 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -