답안 #80729

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
80729 2018-10-22T05:08:31 Z inom Gift (IZhO18_nicegift) C++14
18 / 100
2000 ms 137100 KB
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);

using namespace std;
  
const int N = 2 * 1e5 + 10;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int TN = 1;

int n, k;
set<pair<int, int>> st;
vector<vector<int>> ans;

void solve() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int x; cin >> x; st.insert({-x, i});
    }
    while (!st.empty()) {
        if (sz(st) == 1) {
            cout << -1 << "\n"; return;
        }
        auto a = *st.begin(); st.erase(st.begin());
        auto b = *st.begin(); st.erase(st.begin());
        if (a.fi != -1) {
            st.insert({a.fi + 1, a.se});
        }
        if (b.fi != -1) {
            st.insert({b.fi + 1, b.se});
        }
        vector<int> cur; cur.pb(1); cur.pb(a.se); cur.pb(b.se);
        ans.pb(cur);
    }
    
    cout << sz(ans) << "\n";
    for (auto i: ans) {
        for (auto j: i) {
            cout << j << " ";
        }
        cout << endl;
    }
    return;
}

signed main() {
    // ios_base::sync_with_stdio(0);
    // in; out;  // cin >> TN;
    while (TN--) solve();
    return 0;
 }
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB n=4
2 Correct 2 ms 540 KB n=3
3 Correct 2 ms 752 KB n=3
4 Correct 2 ms 828 KB n=4
5 Correct 2 ms 828 KB n=4
6 Correct 2 ms 828 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB n=4
2 Correct 2 ms 540 KB n=3
3 Correct 2 ms 752 KB n=3
4 Correct 2 ms 828 KB n=4
5 Correct 2 ms 828 KB n=4
6 Correct 2 ms 828 KB n=2
7 Correct 2 ms 828 KB n=5
8 Correct 6 ms 1444 KB n=8
9 Correct 36 ms 1640 KB n=14
10 Correct 22 ms 1640 KB n=11
11 Correct 149 ms 6008 KB n=50000
12 Correct 144 ms 6272 KB n=50000
13 Correct 124 ms 6272 KB n=10
14 Correct 116 ms 6272 KB n=685
15 Correct 120 ms 6272 KB n=623
16 Correct 75 ms 6272 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB n=4
2 Correct 2 ms 540 KB n=3
3 Correct 2 ms 752 KB n=3
4 Correct 2 ms 828 KB n=4
5 Correct 2 ms 828 KB n=4
6 Correct 2 ms 828 KB n=2
7 Correct 2 ms 828 KB n=5
8 Correct 6 ms 1444 KB n=8
9 Correct 36 ms 1640 KB n=14
10 Correct 22 ms 1640 KB n=11
11 Correct 149 ms 6008 KB n=50000
12 Correct 144 ms 6272 KB n=50000
13 Correct 124 ms 6272 KB n=10
14 Correct 116 ms 6272 KB n=685
15 Correct 120 ms 6272 KB n=623
16 Correct 75 ms 6272 KB n=973
17 Incorrect 121 ms 6272 KB Taken too much stones from the heap
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2064 ms 137100 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB n=4
2 Correct 2 ms 540 KB n=3
3 Correct 2 ms 752 KB n=3
4 Correct 2 ms 828 KB n=4
5 Correct 2 ms 828 KB n=4
6 Correct 2 ms 828 KB n=2
7 Correct 2 ms 828 KB n=5
8 Correct 6 ms 1444 KB n=8
9 Correct 36 ms 1640 KB n=14
10 Correct 22 ms 1640 KB n=11
11 Correct 149 ms 6008 KB n=50000
12 Correct 144 ms 6272 KB n=50000
13 Correct 124 ms 6272 KB n=10
14 Correct 116 ms 6272 KB n=685
15 Correct 120 ms 6272 KB n=623
16 Correct 75 ms 6272 KB n=973
17 Incorrect 121 ms 6272 KB Taken too much stones from the heap
18 Halted 0 ms 0 KB -