Submission #69309

#TimeUsernameProblemLanguageResultExecution timeMemory
69309istleminGift (IZhO18_nicegift)C++14
0 / 100
2045 ms82456 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...