Submission #153941

# Submission time Handle Problem Language Result Execution time Memory
153941 2019-09-17T14:35:39 Z andrew Gift (IZhO18_nicegift) C++17
0 / 100
798 ms 87012 KB
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#define fi first
#define se second
#define p_b push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 2e5;
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> void vout(T s){cout << s << endl;exit(0);}

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    ll n, k;
    cin >> n >> k;

    vector <ll> a(n);

    set <pll> st;

    for(int i = 0; i < n; i++){
        cin >> a[i];
        st.insert({a[i], i});
    }

    vector < pair<ll, pll> > ans;

    while(!st.empty()){
        pll xe = *--st.end();
        st.erase(--st.end());
        if(st.empty())vout(-1);
        pll xx = *st.begin();
        st.erase(st.begin());
        xe.fi -= xx.fi;
        ans.p_b({xx.fi, {xe.se, xx.se}});
        if(xe.fi)st.insert(xe);
    }

    cout << ans.size() << "\n";
    for(auto i : ans)cout << i.fi << " " << i.se.fi + 1 << " " << i.se.se + 1 << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 3 ms 376 KB n=3
3 Correct 2 ms 376 KB n=3
4 Incorrect 2 ms 376 KB Jury has the answer but participant has not
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 3 ms 376 KB n=3
3 Correct 2 ms 376 KB n=3
4 Incorrect 2 ms 376 KB Jury has the answer but participant has not
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 3 ms 376 KB n=3
3 Correct 2 ms 376 KB n=3
4 Incorrect 2 ms 376 KB Jury has the answer but participant has not
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 798 ms 87012 KB n=1000000
2 Incorrect 540 ms 57200 KB Expected int32, but "1500001500001" found
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 3 ms 376 KB n=3
3 Correct 2 ms 376 KB n=3
4 Incorrect 2 ms 376 KB Jury has the answer but participant has not
5 Halted 0 ms 0 KB -