# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1107939 |
2024-11-02T11:55:03 Z |
stdfloat |
Gift (IZhO18_nicegift) |
C++17 |
|
433 ms |
77384 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int, int>
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n, k;
cin >> n >> k;
ll sm = 0;
set<pii> s;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
sm += x;
s.insert({x, i});
}
if (sm % k) return cout << -1, 0;
if ((*s.begin()).ff == (*--s.end()).ff) {
if (n % k) {
// assert(false);
return cout << -1, 0;
}
cout << n / k << '\n';
for (int i = 1; i <= n; i += k) {
cout << (*s.begin()).ff << ' ';
for (int j = i; j < i + k; j++)
cout << j << ' ';
cout << '\n';
}
return 0;
}
vector<vector<int>> ans;
while (!s.empty()) {
if (sz(s) < k) return cout << -1, 0;
vector<pii> v;
ans.push_back({});
for (int i = 0; i < k; i++) {
auto t = --s.end();
ans.back().push_back((*t).ss);
if (1 < (*t).ff) v.push_back({(*t).ff - 1, (*t).ss});
s.erase(t);
}
for (auto i : v)
s.insert(i);
}
cout << sz(ans) << '\n';
for (auto i : ans) {
cout << "1 ";
for (auto j : i)
cout << j + 1 << ' ';
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
n=4 |
2 |
Correct |
0 ms |
336 KB |
n=3 |
3 |
Correct |
1 ms |
336 KB |
n=3 |
4 |
Correct |
1 ms |
336 KB |
n=4 |
5 |
Correct |
1 ms |
336 KB |
n=4 |
6 |
Correct |
1 ms |
336 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
n=4 |
2 |
Correct |
0 ms |
336 KB |
n=3 |
3 |
Correct |
1 ms |
336 KB |
n=3 |
4 |
Correct |
1 ms |
336 KB |
n=4 |
5 |
Correct |
1 ms |
336 KB |
n=4 |
6 |
Correct |
1 ms |
336 KB |
n=2 |
7 |
Correct |
0 ms |
336 KB |
n=5 |
8 |
Correct |
2 ms |
1104 KB |
n=8 |
9 |
Correct |
5 ms |
1164 KB |
n=14 |
10 |
Correct |
3 ms |
1104 KB |
n=11 |
11 |
Correct |
26 ms |
6020 KB |
n=50000 |
12 |
Correct |
27 ms |
6204 KB |
n=50000 |
13 |
Correct |
17 ms |
3332 KB |
n=10 |
14 |
Correct |
18 ms |
3076 KB |
n=685 |
15 |
Correct |
20 ms |
3332 KB |
n=623 |
16 |
Correct |
11 ms |
2056 KB |
n=973 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
n=4 |
2 |
Correct |
0 ms |
336 KB |
n=3 |
3 |
Correct |
1 ms |
336 KB |
n=3 |
4 |
Correct |
1 ms |
336 KB |
n=4 |
5 |
Correct |
1 ms |
336 KB |
n=4 |
6 |
Correct |
1 ms |
336 KB |
n=2 |
7 |
Correct |
0 ms |
336 KB |
n=5 |
8 |
Correct |
2 ms |
1104 KB |
n=8 |
9 |
Correct |
5 ms |
1164 KB |
n=14 |
10 |
Correct |
3 ms |
1104 KB |
n=11 |
11 |
Correct |
26 ms |
6020 KB |
n=50000 |
12 |
Correct |
27 ms |
6204 KB |
n=50000 |
13 |
Correct |
17 ms |
3332 KB |
n=10 |
14 |
Correct |
18 ms |
3076 KB |
n=685 |
15 |
Correct |
20 ms |
3332 KB |
n=623 |
16 |
Correct |
11 ms |
2056 KB |
n=973 |
17 |
Correct |
19 ms |
3080 KB |
n=989 |
18 |
Correct |
8 ms |
1360 KB |
n=563 |
19 |
Correct |
14 ms |
2128 KB |
n=592 |
20 |
Correct |
14 ms |
1872 KB |
n=938 |
21 |
Correct |
11 ms |
1872 KB |
n=747 |
22 |
Correct |
12 ms |
1704 KB |
n=991 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
433 ms |
77384 KB |
n=1000000 |
2 |
Correct |
309 ms |
50128 KB |
n=666666 |
3 |
Correct |
155 ms |
29256 KB |
n=400000 |
4 |
Incorrect |
87 ms |
18248 KB |
Jury has the answer but participant has not |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
n=4 |
2 |
Correct |
0 ms |
336 KB |
n=3 |
3 |
Correct |
1 ms |
336 KB |
n=3 |
4 |
Correct |
1 ms |
336 KB |
n=4 |
5 |
Correct |
1 ms |
336 KB |
n=4 |
6 |
Correct |
1 ms |
336 KB |
n=2 |
7 |
Correct |
0 ms |
336 KB |
n=5 |
8 |
Correct |
2 ms |
1104 KB |
n=8 |
9 |
Correct |
5 ms |
1164 KB |
n=14 |
10 |
Correct |
3 ms |
1104 KB |
n=11 |
11 |
Correct |
26 ms |
6020 KB |
n=50000 |
12 |
Correct |
27 ms |
6204 KB |
n=50000 |
13 |
Correct |
17 ms |
3332 KB |
n=10 |
14 |
Correct |
18 ms |
3076 KB |
n=685 |
15 |
Correct |
20 ms |
3332 KB |
n=623 |
16 |
Correct |
11 ms |
2056 KB |
n=973 |
17 |
Correct |
19 ms |
3080 KB |
n=989 |
18 |
Correct |
8 ms |
1360 KB |
n=563 |
19 |
Correct |
14 ms |
2128 KB |
n=592 |
20 |
Correct |
14 ms |
1872 KB |
n=938 |
21 |
Correct |
11 ms |
1872 KB |
n=747 |
22 |
Correct |
12 ms |
1704 KB |
n=991 |
23 |
Correct |
433 ms |
77384 KB |
n=1000000 |
24 |
Correct |
309 ms |
50128 KB |
n=666666 |
25 |
Correct |
155 ms |
29256 KB |
n=400000 |
26 |
Incorrect |
87 ms |
18248 KB |
Jury has the answer but participant has not |
27 |
Halted |
0 ms |
0 KB |
- |