답안 #378838

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378838 2021-03-17T05:56:36 Z wiwiho Gift (IZhO18_nicegift) C++14
0 / 100
420 ms 61732 KB
#include <bits/stdc++.h>

#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define printv(a, b) { \
    for(auto pv : a) b << pv << " "; \
    b << "\n"; \
}

using namespace std;

typedef long long ll;

using pll = pair<ll, ll>;
using pii = pair<int, int>;

const ll MAX = 1LL << 60;

ostream& operator<<(ostream& o, pll p){
    return o << '(' << p.F << ',' << p.S << ')';
}

ll iceil(ll a, ll b){
    return (a + b - 1) / b;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;

    vector<pll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i].F;
        a[i].S = i + 1;
    }
    sort(a.begin(), a.end(), greater<>());

    vector<pair<ll, vector<int>>> ans;
    int lst = 0;
    for(int i = 1; i < n; i++){
        while(a[lst].F == 0) lst++;
        if(i == lst) continue;
        a[lst].F -= a[i].F;
        ans.eb(mp(a[i].F, vector<int>()));
        ans.back().S.eb(a[lst].S);
        ans.back().S.eb(a[i].S);
        a[i].F = 0;
    }

    cout << ans.size() << "\n";
    for(auto& i : ans){
        cout << i.F << " ";
        printv(i.S, cout);
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB n=4
2 Correct 1 ms 364 KB n=3
3 Incorrect 1 ms 364 KB Not all heaps are empty in the end
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB n=4
2 Correct 1 ms 364 KB n=3
3 Incorrect 1 ms 364 KB Not all heaps are empty in the end
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB n=4
2 Correct 1 ms 364 KB n=3
3 Incorrect 1 ms 364 KB Not all heaps are empty in the end
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 420 ms 61732 KB n=1000000
2 Incorrect 305 ms 41244 KB Expected int32, but "1500001500001" found
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB n=4
2 Correct 1 ms 364 KB n=3
3 Incorrect 1 ms 364 KB Not all heaps are empty in the end
4 Halted 0 ms 0 KB -