# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
379004 |
2021-03-17T08:18:23 Z |
wiwiho |
Gift (IZhO18_nicegift) |
C++14 |
|
792 ms |
104728 KB |
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
const ll MAX = 1LL << 60;
ostream& operator<<(ostream& o, pll p){
return o << '(' << p.F << ',' << p.S << ')';
}
ll iceil(ll a, ll b){
return (a + b - 1) / b;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<ll> pos(n + 1), a(n + 1);
ll sum = 0;
for(int i = 1; i <= n; i++){
cin >> a[i];
sum += a[i];
}
if(sum % k){
cout << "-1\n";
return 0;
}
ll len = sum / k;
ll now = 0;
vector<ll> t;
for(int i = 1; i <= n; i++){
if(a[i] > len){
cout << "-1\n";
return 0;
}
now += a[i];
pos[i] = (now - 1) % len;
t.eb(pos[i]);
}
sort(t.begin(), t.end());
t.resize(unique(t.begin(), t.end()) - t.begin());
len = t.size();
vector<vector<int>> ans(len);
int j = -1;
for(int i = 1; i <= n; i++){
int id = lower_bound(t.begin(), t.end(), pos[i]) - t.begin();
for(j = (j + 1) % len; ; j = (j + 1) % len){
ans[j].eb(i);
if(j == id) break;
}
}
cout << len << "\n";
ll lst = -1;
for(int i = 0; i < len; i++){
cout << t[i] - lst << " " ;
printv(ans[i], cout);
lst = t[i];
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Correct |
1 ms |
364 KB |
n=14 |
10 |
Correct |
1 ms |
364 KB |
n=11 |
11 |
Correct |
27 ms |
4460 KB |
n=50000 |
12 |
Correct |
27 ms |
4332 KB |
n=50000 |
13 |
Correct |
0 ms |
364 KB |
n=10 |
14 |
Correct |
1 ms |
364 KB |
n=685 |
15 |
Correct |
1 ms |
364 KB |
n=623 |
16 |
Correct |
1 ms |
364 KB |
n=973 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Correct |
1 ms |
364 KB |
n=14 |
10 |
Correct |
1 ms |
364 KB |
n=11 |
11 |
Correct |
27 ms |
4460 KB |
n=50000 |
12 |
Correct |
27 ms |
4332 KB |
n=50000 |
13 |
Correct |
0 ms |
364 KB |
n=10 |
14 |
Correct |
1 ms |
364 KB |
n=685 |
15 |
Correct |
1 ms |
364 KB |
n=623 |
16 |
Correct |
1 ms |
364 KB |
n=973 |
17 |
Correct |
1 ms |
492 KB |
n=989 |
18 |
Correct |
1 ms |
492 KB |
n=563 |
19 |
Correct |
2 ms |
492 KB |
n=592 |
20 |
Correct |
3 ms |
492 KB |
n=938 |
21 |
Correct |
2 ms |
492 KB |
n=747 |
22 |
Correct |
2 ms |
492 KB |
n=991 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
631 ms |
65668 KB |
n=1000000 |
2 |
Correct |
302 ms |
36176 KB |
n=666666 |
3 |
Correct |
173 ms |
19420 KB |
n=400000 |
4 |
Correct |
395 ms |
44612 KB |
n=285714 |
5 |
Correct |
7 ms |
1008 KB |
n=20000 |
6 |
Correct |
345 ms |
38628 KB |
n=181818 |
7 |
Correct |
4 ms |
768 KB |
n=10000 |
8 |
Correct |
38 ms |
4460 KB |
n=6666 |
9 |
Correct |
3 ms |
492 KB |
n=4000 |
10 |
Correct |
202 ms |
21356 KB |
n=2857 |
11 |
Correct |
1 ms |
364 KB |
n=2000 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Correct |
1 ms |
364 KB |
n=14 |
10 |
Correct |
1 ms |
364 KB |
n=11 |
11 |
Correct |
27 ms |
4460 KB |
n=50000 |
12 |
Correct |
27 ms |
4332 KB |
n=50000 |
13 |
Correct |
0 ms |
364 KB |
n=10 |
14 |
Correct |
1 ms |
364 KB |
n=685 |
15 |
Correct |
1 ms |
364 KB |
n=623 |
16 |
Correct |
1 ms |
364 KB |
n=973 |
17 |
Correct |
1 ms |
492 KB |
n=989 |
18 |
Correct |
1 ms |
492 KB |
n=563 |
19 |
Correct |
2 ms |
492 KB |
n=592 |
20 |
Correct |
3 ms |
492 KB |
n=938 |
21 |
Correct |
2 ms |
492 KB |
n=747 |
22 |
Correct |
2 ms |
492 KB |
n=991 |
23 |
Correct |
631 ms |
65668 KB |
n=1000000 |
24 |
Correct |
302 ms |
36176 KB |
n=666666 |
25 |
Correct |
173 ms |
19420 KB |
n=400000 |
26 |
Correct |
395 ms |
44612 KB |
n=285714 |
27 |
Correct |
7 ms |
1008 KB |
n=20000 |
28 |
Correct |
345 ms |
38628 KB |
n=181818 |
29 |
Correct |
4 ms |
768 KB |
n=10000 |
30 |
Correct |
38 ms |
4460 KB |
n=6666 |
31 |
Correct |
3 ms |
492 KB |
n=4000 |
32 |
Correct |
202 ms |
21356 KB |
n=2857 |
33 |
Correct |
1 ms |
364 KB |
n=2000 |
34 |
Correct |
16 ms |
2544 KB |
n=23514 |
35 |
Correct |
16 ms |
2544 KB |
n=23514 |
36 |
Correct |
1 ms |
364 KB |
n=940 |
37 |
Correct |
1 ms |
364 KB |
n=2 |
38 |
Correct |
100 ms |
13032 KB |
n=100000 |
39 |
Correct |
101 ms |
13032 KB |
n=100000 |
40 |
Correct |
1 ms |
364 KB |
n=10 |
41 |
Correct |
1 ms |
364 KB |
n=100 |
42 |
Correct |
6 ms |
876 KB |
n=1000 |
43 |
Correct |
660 ms |
100432 KB |
n=1000000 |
44 |
Correct |
792 ms |
104728 KB |
n=1000000 |
45 |
Correct |
588 ms |
74192 KB |
n=666666 |
46 |
Correct |
460 ms |
55772 KB |
n=400000 |
47 |
Correct |
203 ms |
19320 KB |
n=2336 |
48 |
Correct |
383 ms |
44636 KB |
n=285714 |
49 |
Correct |
335 ms |
38628 KB |
n=181818 |
50 |
Correct |
239 ms |
25068 KB |
n=40000 |
51 |
Correct |
231 ms |
22768 KB |
n=20000 |
52 |
Correct |
210 ms |
21112 KB |
n=10000 |
53 |
Correct |
205 ms |
24044 KB |
n=6666 |
54 |
Correct |
199 ms |
18156 KB |
n=4000 |
55 |
Correct |
205 ms |
21356 KB |
n=2857 |
56 |
Correct |
205 ms |
17132 KB |
n=2000 |