Submission #69310

# Submission time Handle Problem Language Result Execution time Memory
69310 2018-08-20T12:10:06 Z istlemin Gift (IZhO18_nicegift) C++14
0 / 100
1359 ms 49724 KB
#include<bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

int main(){
	cin.sync_with_stdio(false);
    ll n, k;
    cin>>n>>k;

    vector<pii> a(n);
    rep(i,0,n){
        cin>>a[i].first;
        a[i].second = i;
    }

	sort(all(a));

    vector<tuple<ll,ll,ll> > ans;

    vi left(n);
    rep(i,0,n) left[i] = a[i].first;
    rep(i,0,n-3){
		if(left[i]!=0)
			ans.emplace_back(i,i+1,left[i]);
		left[i+1] -= left[i];
		left[i] = 0;
    }

    if((left[n-3]+left[n-2]+left[n-1])%2==1){
		cout<<-1<<endl;
		return 0;
    }
	if((left[n-3]+left[n-2]-left[n-1])!=0)
		ans.emplace_back(n-3,n-2,(left[n-3]+left[n-2]-left[n-1])/2);
	if((left[n-2]+left[n-1]-left[n-3])!=0)
		ans.emplace_back(n-2,n-1,(left[n-2]+left[n-1]-left[n-3])/2);
	if((left[n-1]+left[n-3]-left[n-2])!=0)
		ans.emplace_back(n-1,n-3,(left[n-1]+left[n-3]-left[n-2])/2);

	cout<<ans.size()<<endl;
    rep(i,0,ans.size()){
		ll x,i1,i2;
		tie(i1,i2,x) = ans[i];
        cout<<x<<" "<<a[i1].second+1<<" "<<a[i2].second+1<<endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n=4
2 Correct 2 ms 356 KB n=3
3 Correct 3 ms 600 KB n=3
4 Correct 2 ms 600 KB n=4
5 Correct 2 ms 648 KB n=4
6 Incorrect 3 ms 648 KB Integer 50 violates the range [1, 2]
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n=4
2 Correct 2 ms 356 KB n=3
3 Correct 3 ms 600 KB n=3
4 Correct 2 ms 600 KB n=4
5 Correct 2 ms 648 KB n=4
6 Incorrect 3 ms 648 KB Integer 50 violates the range [1, 2]
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n=4
2 Correct 2 ms 356 KB n=3
3 Correct 3 ms 600 KB n=3
4 Correct 2 ms 600 KB n=4
5 Correct 2 ms 648 KB n=4
6 Incorrect 3 ms 648 KB Integer 50 violates the range [1, 2]
# Verdict Execution time Memory Grader output
1 Correct 1359 ms 49724 KB n=1000000
2 Incorrect 800 ms 49724 KB Expected int32, but "1500001500001" found
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB n=4
2 Correct 2 ms 356 KB n=3
3 Correct 3 ms 600 KB n=3
4 Correct 2 ms 600 KB n=4
5 Correct 2 ms 648 KB n=4
6 Incorrect 3 ms 648 KB Integer 50 violates the range [1, 2]