This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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){
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;
}
ans.emplace_back(n-3,n-2,(left[n-3]+left[n-2]-left[n-1])/2);
ans.emplace_back(n-2,n-1,(left[n-2]+left[n-1]-left[n-3])/2);
ans.emplace_back(n-1,n-3,(left[n-1]+left[n-3]-left[n-2])/2);
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |