# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
378705 | 8e7 | Gift (IZhO18_nicegift) | C++14 | 654 ms | 524292 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Challenge: Accepted
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#define ll long long
#define maxn 1000005
#define pii pair<int, ll>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
ll a[maxn];
vector<int> val;
int main() {
io
ll n, k;
cin >> n >> k;
for (int i = 0;i < n;i++) {
cin >> a[i];
for (int j = 0;j < a[i];j++) {
val.push_back(i);
}
}
bool poss = val.size() % 2 == 0;
for (int i = 0;i < val.size() / 2;i++) {
if (val[i] == val[i + val.size() / 2]) {
poss = false;
break;
}
}
if (!poss) {
cout << -1 << endl;
} else {
cout << val.size() / 2 << "\n";
for (int i = 0;i < val.size() / 2;i++) {
cout << 1 << " " << val[i]+1 << " " << val[i + val.size() / 2]+1 << "\n";
}
}
}
Compilation message (stderr)
# | 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... |