#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;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Integer 0 violates the range [1, 4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Integer 0 violates the range [1, 4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Integer 0 violates the range [1, 4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2045 ms |
82456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Integer 0 violates the range [1, 4] |
2 |
Halted |
0 ms |
0 KB |
- |