# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
90652 |
2018-12-23T09:03:35 Z |
adlet |
Gift (IZhO18_nicegift) |
C++17 |
|
3 ms |
628 KB |
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const double PI = acos(-1.0);
struct item {
int x, i, j;
};
vector < item > ans;
int n, k, mx, a[N];
ll sum;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
sum += a[i];
mx = max(mx, a[i]);
}
sort(a + 1, a + n + 1);
if (sum % k != 0 || mx > sum / k) {
cout << -1;
return 0;
}
for (int i = 1; i <= n; ++i) {
if (!a[i])
continue;
for (int j = n; j > i; --j) {
if (!a[i])
break;
if (!a[j])
continue;
ans.push_back({1, i, j});
--a[i];
--a[j];
}
}
cout << ans.size() << "\n";
for (auto it : ans) {
cout << it.x << " " << it.i << " " << it.j << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
628 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |