# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
522267 |
2022-02-04T11:23:54 Z |
vonatlus |
Gift (IZhO18_nicegift) |
C++17 |
|
2000 ms |
29536 KB |
/// adil sultanov | vonat1us
#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
using namespace std;
using ll = long long;
using pii = pair<ll, int>;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;
void fin() {
#ifdef AM
freopen(".in", "r", stdin);
#endif
}
const bool flag = 0;
const int N = 1e5+10;
void ma1n() {
ll n, k;
cin >> n >> k;
vector<pii> a(n);
ll sum = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i].x, a[i].y = i;
sum += a[i].x;
}
if (sum%k) {
cout << -1, exit(0);
}
vector<vector<int>> ans;
while (1) {
sort(all(a));
reverse(all(a));
if (a[0].x == 0) break;
for (int i = 1; i < k; ++i) {
if (a[i].x == 0) {
cout << -1, exit(0);
}
}
vector<int> v;
for (int i = 0; i < k; ++i) {
a[i].x--;
v.pb(a[i].y);
}
ans.pb(v);
}
cout << sz(ans) << "\n";
for (auto v : ans) {
cout << "1 ";
for (int x : v) cout << x+1 << " ";
cout << "\n";
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(nullptr), fin();
int ts = 1;
if (flag) {
cin >> ts;
}
while (ts--) {
ma1n();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n=4 |
2 |
Correct |
1 ms |
204 KB |
n=3 |
3 |
Correct |
1 ms |
204 KB |
n=3 |
4 |
Correct |
1 ms |
204 KB |
n=4 |
5 |
Correct |
0 ms |
204 KB |
n=4 |
6 |
Correct |
1 ms |
308 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n=4 |
2 |
Correct |
1 ms |
204 KB |
n=3 |
3 |
Correct |
1 ms |
204 KB |
n=3 |
4 |
Correct |
1 ms |
204 KB |
n=4 |
5 |
Correct |
0 ms |
204 KB |
n=4 |
6 |
Correct |
1 ms |
308 KB |
n=2 |
7 |
Correct |
0 ms |
204 KB |
n=5 |
8 |
Correct |
2 ms |
972 KB |
n=8 |
9 |
Correct |
7 ms |
1160 KB |
n=14 |
10 |
Correct |
4 ms |
956 KB |
n=11 |
11 |
Execution timed out |
2067 ms |
1472 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n=4 |
2 |
Correct |
1 ms |
204 KB |
n=3 |
3 |
Correct |
1 ms |
204 KB |
n=3 |
4 |
Correct |
1 ms |
204 KB |
n=4 |
5 |
Correct |
0 ms |
204 KB |
n=4 |
6 |
Correct |
1 ms |
308 KB |
n=2 |
7 |
Correct |
0 ms |
204 KB |
n=5 |
8 |
Correct |
2 ms |
972 KB |
n=8 |
9 |
Correct |
7 ms |
1160 KB |
n=14 |
10 |
Correct |
4 ms |
956 KB |
n=11 |
11 |
Execution timed out |
2067 ms |
1472 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2094 ms |
29536 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n=4 |
2 |
Correct |
1 ms |
204 KB |
n=3 |
3 |
Correct |
1 ms |
204 KB |
n=3 |
4 |
Correct |
1 ms |
204 KB |
n=4 |
5 |
Correct |
0 ms |
204 KB |
n=4 |
6 |
Correct |
1 ms |
308 KB |
n=2 |
7 |
Correct |
0 ms |
204 KB |
n=5 |
8 |
Correct |
2 ms |
972 KB |
n=8 |
9 |
Correct |
7 ms |
1160 KB |
n=14 |
10 |
Correct |
4 ms |
956 KB |
n=11 |
11 |
Execution timed out |
2067 ms |
1472 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |