Task: | Gift |
Sender: | ollpu |
Submission time: | 2019-02-17 20:35:13 +0200 |
Language: | C++ |
Status: | READY |
Result: | 49 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 7 |
#2 | ACCEPTED | 11 |
#3 | ACCEPTED | 12 |
#4 | ACCEPTED | 19 |
#5 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.02 s | 1, 2, 3, 5 | details |
#2 | ACCEPTED | 0.01 s | 1, 2, 3, 5 | details |
#3 | ACCEPTED | 0.02 s | 1, 2, 3, 5 | details |
#4 | ACCEPTED | 0.01 s | 1, 2, 3, 5 | details |
#5 | ACCEPTED | 0.03 s | 1, 2, 3, 5 | details |
#6 | ACCEPTED | 0.02 s | 1, 2, 3, 5 | details |
#7 | ACCEPTED | 0.03 s | 1, 2, 3, 5 | details |
#8 | ACCEPTED | 0.02 s | 2, 3, 5 | details |
#9 | ACCEPTED | 0.02 s | 2, 3, 5 | details |
#10 | ACCEPTED | 0.02 s | 2, 3, 5 | details |
#11 | ACCEPTED | 0.08 s | 2, 3, 5 | details |
#12 | ACCEPTED | 0.06 s | 2, 3, 5 | details |
#13 | ACCEPTED | 0.04 s | 2, 3, 5 | details |
#14 | ACCEPTED | 0.06 s | 2, 3, 5 | details |
#15 | ACCEPTED | 0.05 s | 2, 3, 5 | details |
#16 | ACCEPTED | 0.04 s | 2, 3, 5 | details |
#17 | ACCEPTED | 0.05 s | 3, 5 | details |
#18 | ACCEPTED | 0.04 s | 3, 5 | details |
#19 | ACCEPTED | 0.05 s | 3, 5 | details |
#20 | ACCEPTED | 0.05 s | 3, 5 | details |
#21 | ACCEPTED | 0.04 s | 3, 5 | details |
#22 | ACCEPTED | 0.05 s | 3, 5 | details |
#23 | ACCEPTED | 0.35 s | 4, 5 | details |
#24 | ACCEPTED | 0.24 s | 4, 5 | details |
#25 | ACCEPTED | 0.14 s | 4, 5 | details |
#26 | ACCEPTED | 0.11 s | 4, 5 | details |
#27 | ACCEPTED | 0.04 s | 4, 5 | details |
#28 | ACCEPTED | 0.09 s | 4, 5 | details |
#29 | ACCEPTED | 0.01 s | 4, 5 | details |
#30 | ACCEPTED | 0.02 s | 4, 5 | details |
#31 | ACCEPTED | 0.01 s | 4, 5 | details |
#32 | ACCEPTED | 0.07 s | 4, 5 | details |
#33 | ACCEPTED | 0.02 s | 4, 5 | details |
#34 | TIME LIMIT EXCEEDED | -- | 5 | details |
#35 | TIME LIMIT EXCEEDED | -- | 5 | details |
#36 | TIME LIMIT EXCEEDED | -- | 5 | details |
#37 | ACCEPTED | 0.03 s | 4, 5 | details |
#38 | TIME LIMIT EXCEEDED | -- | 5 | details |
#39 | TIME LIMIT EXCEEDED | -- | 5 | details |
#40 | TIME LIMIT EXCEEDED | -- | 5 | details |
#41 | TIME LIMIT EXCEEDED | -- | 5 | details |
#42 | TIME LIMIT EXCEEDED | -- | 5 | details |
#43 | TIME LIMIT EXCEEDED | -- | 5 | details |
#44 | TIME LIMIT EXCEEDED | -- | 5 | details |
#45 | TIME LIMIT EXCEEDED | -- | 5 | details |
#46 | TIME LIMIT EXCEEDED | -- | 5 | details |
#47 | TIME LIMIT EXCEEDED | -- | 5 | details |
#48 | TIME LIMIT EXCEEDED | -- | 5 | details |
#49 | TIME LIMIT EXCEEDED | -- | 5 | details |
#50 | TIME LIMIT EXCEEDED | -- | 5 | details |
#51 | TIME LIMIT EXCEEDED | -- | 5 | details |
#52 | TIME LIMIT EXCEEDED | -- | 5 | details |
#53 | TIME LIMIT EXCEEDED | -- | 5 | details |
#54 | TIME LIMIT EXCEEDED | -- | 5 | details |
#55 | TIME LIMIT EXCEEDED | -- | 5 | details |
#56 | TIME LIMIT EXCEEDED | -- | 5 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:44:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] while (s.size() >= k) { ~~~~~~~~~^~~~
Code
#include <bits/stdc++.h> using namespace std; #define F first #define S second int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; long t[n]; bool aeq = 1; for (int i = 0; i < n; ++i) { cin >> t[i]; if (i && t[i] != t[i-1]) aeq = 0; } if (aeq) { if (t[0]*n %k) { cout << -1 << endl; return 0; } long lc = n%k+k; long g = __gcd(lc, (long)k); cout << lc/g + (n-lc)/k << endl; for (int i = 0; i < lc; i += g) { cout << t[0]*g/k << " "; for (int j = 0; j < k; ++j) { cout << (i+j)%lc +1 << " "; } cout << "\n"; } for (int i = lc; i < n; i += k) { cout << t[0] << " "; for (int j = 0; j < k; ++j) { cout << (i+j) +1 << " "; } cout << "\n"; } } else { priority_queue<pair<long, int>> s; for (int i = 0; i < n; ++i) { s.emplace(t[i], i); } vector<vector<int>> ops; while (s.size() >= k) { vector<pair<long, int>> ch; ops.emplace_back(); for (int j = 0; j < k; ++j) { ch.push_back(s.top()); ops.back().push_back(ch.back().S); s.pop(); } for (auto p : ch) { if (--p.F) { s.push(p); } } } if (s.size() != 0) { cout << -1 << endl; return 0; } cout << ops.size() << endl; for (auto &v : ops) { cout << "1 "; for (int x : v) cout << x+1 << " "; cout << "\n"; } } }
Test details
Test 1
Group: 1, 2, 3, 5
Verdict: ACCEPTED
input |
---|
4 2
2 3 3 2 |
correct output |
---|
3
2 3 1 1 3 2 2 2 4 |
user output |
---|
5 1 3 2 1 4 3 1 2 1 1 4 3 ... |
Test 2
Group: 1, 2, 3, 5
Verdict: ACCEPTED
input |
---|
3 2
2 1 1 |
correct output |
---|
2
1 1 2 1 1 3 |
user output |
---|
2 1 1 3 1 2 1 |
Test 3
Group: 1, 2, 3, 5
Verdict: ACCEPTED
input |
---|
3 2
1 2 4 |
correct output |
---|
-1 |
user output |
---|
-1 |
Test 4
Group: 1, 2, 3, 5
Verdict: ACCEPTED
input |
---|
4 2
1 2 3 4 |
correct output |
---|
3
1 1 3 2 2 4 2 3 4 |
user output |
---|
5 1 4 3 1 4 3 1 4 2 1 4 3 ... |
Test 5
Group: 1, 2, 3, 5
Verdict: ACCEPTED
input |
---|
4 2
1 2 1 5 |
correct output |
---|
-1 |
user output |
---|
-1 |
Test 6
Group: 1, 2, 3, 5
Verdict: ACCEPTED
input |
---|
2 2
4 5 |
correct output |
---|
-1 |
user output |
---|
-1 |
Test 7
Group: 1, 2, 3, 5
Verdict: ACCEPTED
input |
---|
5 2
2 1 3 1 1 |
correct output |
---|
3
2 1 3 1 2 4 1 3 5 |
user output |
---|
4 1 3 1 1 3 5 1 4 3 1 2 1 |
Test 8
Group: 2, 3, 5
Verdict: ACCEPTED
input |
---|
8 2
1 1 9101 17 161 57013 7 567 |
correct output |
---|
-1 |
user output |
---|
-1 |
Test 9
Group: 2, 3, 5
Verdict: ACCEPTED
input |
---|
14 2
36 117 358 64 1319 1355 5322 5... |
correct output |
---|
14
36 1 12 117 2 12 358 3 12 64 4 12 ... |
user output |
---|
14186 1 13 12 1 13 12 1 13 12 1 13 12 ... Truncated |
Test 10
Group: 2, 3, 5
Verdict: ACCEPTED
input |
---|
11 2
1 7192 2 49 3973 1 1 68 5274 6... |
correct output |
---|
11
1 1 5 2586 2 5 1 2 6 1 2 7 ... |
user output |
---|
8630 1 2 9 1 2 9 1 2 9 1 2 9 ... Truncated |
Test 11
Group: 2, 3, 5
Verdict: ACCEPTED
input |
---|
50000 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
42250
1 1 33212 1 2 33212 1 3 33212 1 4 33212 ... |
user output |
---|
50000 1 33212 41667 1 33212 41667 1 33212 41667 1 33212 41667 ... Truncated |
Test 12
Group: 2, 3, 5
Verdict: ACCEPTED
input |
---|
50000 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
40020
1 1 27450 1 2 27450 1 3 27450 1 4 27450 ... |
user output |
---|
50000 1 35035 5675 1 35035 5675 1 35035 5675 1 35035 5675 ... Truncated |
Test 13
Group: 2, 3, 5
Verdict: ACCEPTED
input |
---|
10 2
2730 1860 241 33771 20985 1391... |
correct output |
---|
10
2730 1 5 1860 2 5 241 3 5 4756 4 5 ... |
user output |
---|
50000 1 4 10 1 4 10 1 4 10 1 4 10 ... Truncated |
Test 14
Group: 2, 3, 5
Verdict: ACCEPTED
input |
---|
685 2
118 132 114 115 123 136 122 10... |
correct output |
---|
683
21 1 340 97 1 341 36 2 341 96 2 342 ... |
user output |
---|
41835 1 123 513 1 123 513 1 384 123 1 513 384 ... Truncated |
Test 15
Group: 2, 3, 5
Verdict: ACCEPTED
input |
---|
623 2
150 137 159 157 138 153 137 14... |
correct output |
---|
622
77 1 312 73 1 313 72 2 313 65 2 314 ... |
user output |
---|
46071 1 582 398 1 582 30 1 582 398 1 582 30 ... Truncated |
Test 16
Group: 2, 3, 5
Verdict: ACCEPTED
input |
---|
973 2
58 52 54 57 52 71 46 58 64 45 ... |
correct output |
---|
963
48 1 490 10 1 491 44 2 491 8 2 492 ... |
user output |
---|
25345 1 892 304 1 892 304 1 892 849 1 304 892 ... Truncated |
Test 17
Group: 3, 5
Verdict: ACCEPTED
input |
---|
989 3
102 100 91 75 103 79 85 83 98 ... |
correct output |
---|
982
10 1 328 659 33 1 329 659 59 1 329 660 4 2 329 660 ... |
user output |
---|
31704 1 316 170 855 1 431 316 170 1 855 814 431 1 316 170 855 ... Truncated |
Test 18
Group: 3, 5
Verdict: ACCEPTED
input |
---|
563 8
91 104 85 106 99 84 94 118 94 ... |
correct output |
---|
547
21 1 71 143 213 283 355 425 49... |
user output |
---|
6612 1 257 523 473 263 8 533 285 47... Truncated |
Test 19
Group: 3, 5
Verdict: ACCEPTED
input |
---|
592 23
161 178 166 168 144 152 152 16... |
correct output |
---|
547
6 1 26 52 78 104 130 156 182 2... |
user output |
---|
4159 1 94 396 426 200 543 498 475 4... Truncated |
Test 20
Group: 3, 5
Verdict: ACCEPTED
input |
---|
938 15
102 104 89 123 105 111 90 98 9... |
correct output |
---|
871
5 1 62 125 188 251 313 377 439... |
user output |
---|
6196 1 931 107 217 94 684 929 4 591... Truncated |
Test 21
Group: 3, 5
Verdict: ACCEPTED
input |
---|
747 10
96 88 99 82 108 68 82 110 97 8... |
correct output |
---|
704
16 1 74 149 224 298 373 449 52... |
user output |
---|
6771 1 638 172 18 537 649 313 685 8... Truncated |
Test 22
Group: 3, 5
Verdict: ACCEPTED
input |
---|
991 13
83 76 94 77 76 88 79 91 85 69 ... |
correct output |
---|
930
17 1 76 152 229 305 381 458 53... |
user output |
---|
6049 1 739 37 171 940 835 429 22 12... Truncated |
Test 23
Group: 4, 5
Verdict: ACCEPTED
input |
---|
1000000 2
1000000000000 1000000000000 10... |
correct output |
---|
500000
1000000000000 1 500001 1000000000000 2 500002 1000000000000 3 500003 1000000000000 4 500004 ... |
user output |
---|
500000 1000000000000 1 2 1000000000000 3 4 1000000000000 5 6 1000000000000 7 8 ... Truncated |
Test 24
Group: 4, 5
Verdict: ACCEPTED
input |
---|
666666 3
1500001500001 1500001500001 15... |
correct output |
---|
222222
1500001500001 1 222223 444445 ... |
user output |
---|
222222 1500001500001 1 2 3 1500001500001 4 5 6 1500001500001 7 8 9 1500001500001 10 11 ... Truncated |
Test 25
Group: 4, 5
Verdict: ACCEPTED
input |
---|
400000 5
2500000000000 2500000000000 25... |
correct output |
---|
80000
2500000000000 1 80001 160001 2... |
user output |
---|
80000 2500000000000 1 2 3 4 5 2500000000000 6 7 8 9 10 2500000000000 11 12 13 14 15 250 ... Truncated |
Test 26
Group: 4, 5
Verdict: ACCEPTED
input |
---|
285714 7
3500003500000 3500003500000 35... |
correct output |
---|
285714
500000500000 1 40817 81633 122... |
user output |
---|
40824 500000500000 1 2 3 4 5 6 7 500000500000 2 3 4 5 6 7 8 500000500000 3 4 5 6 7 8 9 ... Truncated |
Test 27
Group: 4, 5
Verdict: ACCEPTED
input |
---|
20000 100
50000000000000 50000000000000 ... |
correct output |
---|
200
50000000000000 1 201 401 601 8... |
user output |
---|
200 50000000000000 1 2 3 4 5 6 7 8... Truncated |
Test 28
Group: 4, 5
Verdict: ACCEPTED
input |
---|
181818 11
5500005500000 5500005500000 55... |
correct output |
---|
181818
500000500000 1 16529 33058 495... |
user output |
---|
16548 500000500000 1 2 3 4 5 6 7 8 9... Truncated |
Test 29
Group: 4, 5
Verdict: ACCEPTED
input |
---|
10000 200
100000000000000 10000000000000... |
correct output |
---|
50
100000000000000 1 51 101 151 2... |
user output |
---|
50 100000000000000 1 2 3 4 5 6 7 ... Truncated |
Test 30
Group: 4, 5
Verdict: ACCEPTED
input |
---|
6666 300
150015001500150 15001500150015... |
correct output |
---|
1111
3000300030003 1 23 45 67 89 11... |
user output |
---|
82 3000300030003 1 2 3 4 5 6 7 8 ... Truncated |
Test 31
Group: 4, 5
Verdict: ACCEPTED
input |
---|
4000 500
250000000000000 25000000000000... |
correct output |
---|
8
250000000000000 1 9 17 25 33 4... |
user output |
---|
8 250000000000000 1 2 3 4 5 6 7 ... Truncated |
Test 32
Group: 4, 5
Verdict: ACCEPTED
input |
---|
2857 700
350017500875000 35001750087500... |
correct output |
---|
2857
500025001250 1 5 9 13 17 21 25... |
user output |
---|
760 500025001250 1 2 3 4 5 6 7 8 9... Truncated |
Test 33
Group: 4, 5
Verdict: ACCEPTED
input |
---|
2000 1000
500000000000000 50000000000000... |
correct output |
---|
2
500000000000000 1 3 5 7 9 11 1... |
user output |
---|
2 500000000000000 1 2 3 4 5 6 7 ... Truncated |
Test 34
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
23514 2
18103 5348 3625 12835 15660 90... |
correct output |
---|
23513
6865 1 11793 11202 1 11794 36 1 11795 5348 2 11795 ... |
user output |
---|
(empty) |
Test 35
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
23514 2
18292 21082 22492 20359 17760 ... |
correct output |
---|
23514
8265 1 11746 8926 1 11747 1101 1 11748 9890 2 11748 ... |
user output |
---|
(empty) |
Test 36
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
940 2
73 1 1 1 1 1 1 1 1 1 1 1 1 1 1... |
correct output |
---|
940
73 1 640 1 2 640 1 3 640 1 4 640 ... |
user output |
---|
(empty) |
Test 37
Group: 4, 5
Verdict: ACCEPTED
input |
---|
2 2
50000000000000 50000000000000 |
correct output |
---|
1
50000000000000 1 2 |
user output |
---|
1 50000000000000 1 2 |
Test 38
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 5
134 153 148 128 126 146 165 16... |
correct output |
---|
98678
33 1 20010 40009 59997 80000 10 1 20010 40010 59997 80000 3 1 20010 40010 59997 80001 58 1 20011 40010 59997 80001 ... |
user output |
---|
(empty) |
Test 39
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 5
152 137 163 145 132 157 183 15... |
correct output |
---|
98711
1 1 19996 40005 60007 80009 71 1 19996 40005 60008 80009 46 1 19997 40005 60008 80009 24 1 19997 40005 60008 80010 ... |
user output |
---|
(empty) |
Test 40
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
10 5
1499332 1501242 1498874 150016... |
correct output |
---|
10
574 1 2 5 7 9 1498721 1 3 5 7 9 37 1 3 6 7 9 116 2 3 6 7 9 ... |
user output |
---|
(empty) |
Test 41
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 50
1002132999440 1001266333597 10... |
correct output |
---|
100
1267999683 1 2 4 6 8 10 12 14 ... |
user output |
---|
(empty) |
Test 42
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 50
100346633179 101226632849 1003... |
correct output |
---|
1000
1839998687 1 20 40 60 80 100 1... |
user output |
---|
(empty) |
Test 43
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000000 2
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
999996
1 1 707107 2 2 707107 3 3 707107 4 4 707107 ... |
user output |
---|
(empty) |
Test 44
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000000 2
999999551533 1000000473528 100... |
correct output |
---|
1000000
146192314 1 500000 999853359219 1 500001 146463134 2 500001 999854010394 2 500002 ... |
user output |
---|
(empty) |
Test 45
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
666666 3
1500001336447 1500001298201 15... |
correct output |
---|
666666
1499958849879 1 222223 444445 ... |
user output |
---|
(empty) |
Test 46
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
400000 5
2499999946636 2500000060399 25... |
correct output |
---|
400000
2499910300054 1 80001 160001 2... |
user output |
---|
(empty) |
Test 47
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
2336 856
42808218598 42808218183 428082... |
correct output |
---|
2336
10257 1 3 6 9 11 14 17 20 22 2... |
user output |
---|
(empty) |
Test 48
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
285714 7
3500003576920 3500003507271 35... |
correct output |
---|
285714
499997032073 1 40817 81633 122... |
user output |
---|
(empty) |
Test 49
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
181818 11
5500005515540 5500005459088 55... |
correct output |
---|
181818
500002072749 1 16529 33058 495... |
user output |
---|
(empty) |
Test 50
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
40000 50
25000000005730 24999999994976 ... |
correct output |
---|
40000
4690 1 800 1600 2401 3200 4001... |
user output |
---|
(empty) |
Test 51
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
20000 100
50000000003586 50000000000483 ... |
correct output |
---|
19998
3844 1 201 401 600 801 1001 12... |
user output |
---|
(empty) |
Test 52
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
10000 200
100000000000713 99999999996921... |
correct output |
---|
9995
84 1 51 100 151 201 250 301 35... |
user output |
---|
(empty) |
Test 53
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
6666 300
150015001497695 15001500150098... |
correct output |
---|
6666
6771 1 23 45 67 89 112 134 156... |
user output |
---|
(empty) |
Test 54
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
4000 500
250000000001078 24999999999820... |
correct output |
---|
3979
93 1 9 16 24 32 40 48 56 64 72... |
user output |
---|
(empty) |
Test 55
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
2857 700
350017500876401 35001750087429... |
correct output |
---|
2857
500024974229 1 5 9 13 17 21 25... |
user output |
---|
(empty) |
Test 56
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
2000 1000
499999999999833 50000000000035... |
correct output |
---|
1955
1 1 2 4 6 8 11 13 15 17 19 21 ... |
user output |
---|
(empty) |