Task: | Gift |
Sender: | Olli |
Submission time: | 2019-02-16 16:04:06 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
#4 | WRONG ANSWER | 0 |
#5 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.05 s | 1, 2, 3, 5 | details |
#2 | ACCEPTED | 0.05 s | 1, 2, 3, 5 | details |
#3 | ACCEPTED | 0.04 s | 1, 2, 3, 5 | details |
#4 | ACCEPTED | 0.06 s | 1, 2, 3, 5 | details |
#5 | ACCEPTED | 0.06 s | 1, 2, 3, 5 | details |
#6 | ACCEPTED | 0.05 s | 1, 2, 3, 5 | details |
#7 | WRONG ANSWER | 0.05 s | 1, 2, 3, 5 | details |
#8 | ACCEPTED | 0.06 s | 2, 3, 5 | details |
#9 | WRONG ANSWER | 0.07 s | 2, 3, 5 | details |
#10 | WRONG ANSWER | 0.05 s | 2, 3, 5 | details |
#11 | WRONG ANSWER | 0.07 s | 2, 3, 5 | details |
#12 | WRONG ANSWER | 0.09 s | 2, 3, 5 | details |
#13 | WRONG ANSWER | 0.05 s | 2, 3, 5 | details |
#14 | WRONG ANSWER | 0.04 s | 2, 3, 5 | details |
#15 | WRONG ANSWER | 0.05 s | 2, 3, 5 | details |
#16 | WRONG ANSWER | 0.05 s | 2, 3, 5 | details |
#17 | WRONG ANSWER | 0.05 s | 3, 5 | details |
#18 | WRONG ANSWER | 0.05 s | 3, 5 | details |
#19 | WRONG ANSWER | 0.05 s | 3, 5 | details |
#20 | WRONG ANSWER | 0.07 s | 3, 5 | details |
#21 | WRONG ANSWER | 0.06 s | 3, 5 | details |
#22 | WRONG ANSWER | 0.05 s | 3, 5 | details |
#23 | WRONG ANSWER | 1.16 s | 4, 5 | details |
#24 | WRONG ANSWER | 0.73 s | 4, 5 | details |
#25 | WRONG ANSWER | 0.48 s | 4, 5 | details |
#26 | WRONG ANSWER | 0.34 s | 4, 5 | details |
#27 | WRONG ANSWER | 0.07 s | 4, 5 | details |
#28 | WRONG ANSWER | 0.24 s | 4, 5 | details |
#29 | WRONG ANSWER | 0.07 s | 4, 5 | details |
#30 | WRONG ANSWER | 0.07 s | 4, 5 | details |
#31 | WRONG ANSWER | 0.06 s | 4, 5 | details |
#32 | WRONG ANSWER | 0.07 s | 4, 5 | details |
#33 | WRONG ANSWER | 0.06 s | 4, 5 | details |
#34 | WRONG ANSWER | 0.07 s | 5 | details |
#35 | WRONG ANSWER | 0.07 s | 5 | details |
#36 | WRONG ANSWER | 0.06 s | 5 | details |
#37 | ACCEPTED | 0.06 s | 4, 5 | details |
#38 | WRONG ANSWER | 0.11 s | 5 | details |
#39 | WRONG ANSWER | 0.11 s | 5 | details |
#40 | WRONG ANSWER | 0.04 s | 5 | details |
#41 | WRONG ANSWER | 0.05 s | 5 | details |
#42 | WRONG ANSWER | 0.05 s | 5 | details |
#43 | WRONG ANSWER | 0.89 s | 5 | details |
#44 | WRONG ANSWER | 1.73 s | 5 | details |
#45 | WRONG ANSWER | 1.13 s | 5 | details |
#46 | WRONG ANSWER | 0.65 s | 5 | details |
#47 | WRONG ANSWER | 0.08 s | 5 | details |
#48 | WRONG ANSWER | 0.46 s | 5 | details |
#49 | WRONG ANSWER | 0.29 s | 5 | details |
#50 | WRONG ANSWER | 0.10 s | 5 | details |
#51 | WRONG ANSWER | 0.07 s | 5 | details |
#52 | WRONG ANSWER | 0.06 s | 5 | details |
#53 | WRONG ANSWER | 0.07 s | 5 | details |
#54 | WRONG ANSWER | 0.06 s | 5 | details |
#55 | WRONG ANSWER | 0.07 s | 5 | details |
#56 | WRONG ANSWER | 0.06 s | 5 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:92:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(i = 0; i < ne.size(); ++i) { ~~^~~~~~~~~~~ input/code.cpp:101:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j = 0; j < mov[i].size(); ++j) { ~~^~~~~~~~~~~~~~~
Code
#include <iostream> #include <vector> #include <algorithm> #include <set> #include <unordered_map> #include <math.h> using namespace std; const int N = 1e6 + 5; const int M = 131072; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define F first #define S second ll t[N]; set<pll> s; vector<int> mov[2*N]; int main() { int n, k; cin >> n >> k; ll sum = 0; for(int i = 1; i <= n; ++i) { ll a; cin >> a; t[i] = a; s.insert({a, i}); sum += a; } if(sum%k != 0) { cout << -1 << "\n"; return 0; } for(int i = 1; i <= n; ++i) { if(t[i] > sum/k) { cout << -1 << "\n"; return 0; } } if(n == k) { for(int i = 1; i <= n; ++i) { if(t[i] != sum/k) { cout << -1 << "\n"; return 0; } } cout << 1 << "\n"; cout << sum/k << " "; for(int i = 1; i <= n; ++i) { cout << i << " "; } cout << "\n"; return 0; } int c = 1; while(sum > 0 && c < 100) { ll k1th; set<pll>::iterator it = s.end(); --it; int i = n; while(i != n - k) { --it; --i; } k1th = (*it).first; // cout << "Sum : " << sum << " and k+1:th largest is " << k1th << "\n"; ll x = sum/k - k1th; it = s.end(); vector<pll> ne; mov[c].push_back(x); for(i = n; i > n-k; --i) { --it; ne.push_back({(*it).first - x, (*it).second}); mov[c].push_back((*it).second); } for(i = n; i > n-k; --i) { it = s.end(); --it; s.erase(it); } for(i = 0; i < ne.size(); ++i) { s.insert(ne[i]); } sum -= x*k; ++c; } cout << c-1 << "\n"; for(int i = 1; i < c; ++i) { for(int j = 0; j < mov[i].size(); ++j) { cout << mov[i][j] << " "; } 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 |
---|
2 3 3 2 2 4 1 |
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 |
---|
3 3 4 3 1 2 4 1 2 1 |
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: WRONG ANSWER
input |
---|
5 2
2 1 3 1 1 |
correct output |
---|
3
2 1 3 1 2 4 1 3 5 |
user output |
---|
99 3 3 1 0 5 4 0 5 4 0 5 4 ... Truncated |
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: WRONG ANSWER
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 |
---|
99 8864 13 12 3967 7 13 36 7 6 0 7 6 ... Truncated |
Test 10
Group: 2, 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 4657 2 9 3275 5 2 81 10 5 0 10 9 ... Truncated |
Test 11
Group: 2, 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 49294 33212 41667 653 17435 3767 47 31460 17435 0 43663 31460 ... Truncated |
Test 12
Group: 2, 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 41636 35035 5675 4432 22494 35120 877 27450 22494 0 37080 27450 ... Truncated |
Test 13
Group: 2, 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 29015 4 10 16229 5 9 2026 5 4 0 5 4 ... Truncated |
Test 14
Group: 2, 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 41678 123 513 7 384 80 1 384 87 0 479 384 ... Truncated |
Test 15
Group: 2, 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 45891 582 398 2 30 426 1 30 26 0 533 30 ... Truncated |
Test 16
Group: 2, 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 25273 892 304 2 849 6 0 929 849 0 929 849 ... Truncated |
Test 17
Group: 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 31578 316 170 855 3 431 814 203 1 431 127 814 1 431 196 127 ... Truncated |
Test 18
Group: 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 6496 257 523 473 263 8 533 285... Truncated |
Test 19
Group: 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 3976 94 396 426 200 543 498 47... Truncated |
Test 20
Group: 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 6076 931 107 217 94 684 929 4 ... Truncated |
Test 21
Group: 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 6660 638 172 18 537 649 313 68... Truncated |
Test 22
Group: 3, 5
Verdict: WRONG ANSWER
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 |
---|
99 5951 739 37 171 940 835 429 22... Truncated |
Test 23
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
1000000 2
1000000000000 1000000000000 10... |
correct output |
---|
500000
1000000000000 1 500001 1000000000000 2 500002 1000000000000 3 500003 1000000000000 4 500004 ... |
user output |
---|
99 -15929344 1000000 999999 0 999998 999997 0 999998 999997 0 999998 999997 ... Truncated |
Test 24
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
666666 3
1500001500001 1500001500001 15... |
correct output |
---|
222222
1500001500001 1 222223 444445 ... |
user output |
---|
99 1309747181 666666 666665 66666... Truncated |
Test 25
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
400000 5
2500000000000 2500000000000 25... |
correct output |
---|
80000
2500000000000 1 80001 160001 2... |
user output |
---|
99 -1485350912 400000 399999 3999... Truncated |
Test 26
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
285714 7
3500003500000 3500003500000 35... |
correct output |
---|
285714
500000500000 1 40817 81633 122... |
user output |
---|
99 -1658370976 285714 285713 2857... Truncated |
Test 27
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
20000 100
50000000000000 50000000000000 ... |
correct output |
---|
200
50000000000000 1 201 401 601 8... |
user output |
---|
99 -410787840 20000 19999 19998 1... Truncated |
Test 28
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
181818 11
5500005500000 5500005500000 55... |
correct output |
---|
181818
500000500000 1 16529 33058 495... |
user output |
---|
99 -1801696032 181818 181817 1818... Truncated |
Test 29
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
10000 200
100000000000000 10000000000000... |
correct output |
---|
50
100000000000000 1 51 101 151 2... |
user output |
---|
99 661012480 10000 9999 9998 9997... Truncated |
Test 30
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
6666 300
150015001500150 15001500150015... |
correct output |
---|
1111
3000300030003 1 23 45 67 89 11... |
user output |
---|
99 241187679 6666 6665 6664 6663 ... Truncated |
Test 31
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
4000 500
250000000000000 25000000000000... |
correct output |
---|
8
250000000000000 1 9 17 25 33 4... |
user output |
---|
99 -1604624384 4000 3999 3998 399... Truncated |
Test 32
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
2857 700
350017500875000 35001750087500... |
correct output |
---|
2857
500025001250 1 5 9 13 17 21 25... |
user output |
---|
99 1740324730 2857 2856 2855 2854... Truncated |
Test 33
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
2000 1000
500000000000000 50000000000000... |
correct output |
---|
2
500000000000000 1 3 5 7 9 11 1... |
user output |
---|
2 1382236160 2000 1999 1998 1997... Truncated |
Test 34
Group: 5
Verdict: WRONG ANSWER
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 |
---|
99 138200105 6280 1884 2 7660 22648 1 11004 7660 0 22648 11004 ... Truncated |
Test 35
Group: 5
Verdict: WRONG ANSWER
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 |
---|
99 138200105 6401 22796 2 15829 19205 1 15829 14764 0 19205 19065 ... Truncated |
Test 36
Group: 5
Verdict: WRONG ANSWER
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 |
---|
99 415877059 719 181 40291192 226 719 2939785 640 226 0 640 501 ... Truncated |
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: WRONG ANSWER
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 |
---|
99 2999800 30828 5309 56413 75067... Truncated |
Test 39
Group: 5
Verdict: WRONG ANSWER
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 |
---|
99 2999801 60605 63696 91012 3818... Truncated |
Test 40
Group: 5
Verdict: WRONG ANSWER
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 |
---|
99 1500170 7 2 9 4 6 1498301 10 5 1 3 8 956 10 7 5 2 1 302 10 7 3 5 8 ... Truncated |
Test 41
Group: 5
Verdict: WRONG ANSWER
input |
---|
100 50
1002132999440 1001266333597 10... |
correct output |
---|
100
1267999683 1 2 4 6 8 10 12 14 ... |
user output |
---|
99 -920379865 35 32 73 89 34 52 4... Truncated |
Test 42
Group: 5
Verdict: WRONG ANSWER
input |
---|
1000 50
100346633179 101226632849 1003... |
correct output |
---|
1000
1839998687 1 20 40 60 80 100 1... |
user output |
---|
99 291155562 543 880 250 441 665 ... Truncated |
Test 43
Group: 5
Verdict: WRONG ANSWER
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 |
---|
99 891146834 1000000 999999 2 999998 999997 1 999998 999996 0 999998 999997 ... Truncated |
Test 44
Group: 5
Verdict: WRONG ANSWER
input |
---|
1000000 2
999999551533 1000000473528 100... |
correct output |
---|
1000000
146192314 1 500000 999853359219 1 500001 146463134 2 500001 999854010394 2 500002 ... |
user output |
---|
99 -16429341 651007 282728 2 890704 610308 1 890704 142216 0 890704 610308 ... Truncated |
Test 45
Group: 5
Verdict: WRONG ANSWER
input |
---|
666666 3
1500001336447 1500001298201 15... |
correct output |
---|
666666
1499958849879 1 222223 444445 ... |
user output |
---|
99 1309524962 116528 487981 40296... Truncated |
Test 46
Group: 5
Verdict: WRONG ANSWER
input |
---|
400000 5
2499999946636 2500000060399 25... |
correct output |
---|
400000
2499910300054 1 80001 160001 2... |
user output |
---|
99 -1485550906 148576 392209 1004... Truncated |
Test 47
Group: 5
Verdict: WRONG ANSWER
input |
---|
2336 856
42808218598 42808218183 428082... |
correct output |
---|
2336
10257 1 3 6 9 11 14 17 20 22 2... |
user output |
---|
99 999766385 879 1997 955 1398 87... Truncated |
Test 48
Group: 5
Verdict: WRONG ANSWER
input |
---|
285714 7
3500003576920 3500003507271 35... |
correct output |
---|
285714
499997032073 1 40817 81633 122... |
user output |
---|
99 -1658370972 240082 233991 1592... Truncated |
Test 49
Group: 5
Verdict: WRONG ANSWER
input |
---|
181818 11
5500005515540 5500005459088 55... |
correct output |
---|
181818
500002072749 1 16529 33058 495... |
user output |
---|
99 -1801696026 118480 130508 1066... Truncated |
Test 50
Group: 5
Verdict: WRONG ANSWER
input |
---|
40000 50
25000000005730 24999999994976 ... |
correct output |
---|
40000
4690 1 800 1600 2401 3200 4001... |
user output |
---|
99 459481619 30890 453 25541 3668... Truncated |
Test 51
Group: 5
Verdict: WRONG ANSWER
input |
---|
20000 100
50000000003586 50000000000483 ... |
correct output |
---|
19998
3844 1 201 401 600 801 1001 12... |
user output |
---|
99 -410797739 5563 2781 2884 2088... Truncated |
Test 52
Group: 5
Verdict: WRONG ANSWER
input |
---|
10000 200
100000000000713 99999999996921... |
correct output |
---|
9995
84 1 51 100 151 201 250 301 35... |
user output |
---|
99 661007681 3131 6034 4334 5327 ... Truncated |
Test 53
Group: 5
Verdict: WRONG ANSWER
input |
---|
6666 300
150015001497695 15001500150098... |
correct output |
---|
6666
6771 1 23 45 67 89 112 134 156... |
user output |
---|
99 241184647 861 2102 2478 2293 2... Truncated |
Test 54
Group: 5
Verdict: WRONG ANSWER
input |
---|
4000 500
250000000001078 24999999999820... |
correct output |
---|
3979
93 1 9 16 24 32 40 48 56 64 72... |
user output |
---|
99 -1604625883 2830 1919 1773 120... Truncated |
Test 55
Group: 5
Verdict: WRONG ANSWER
input |
---|
2857 700
350017500876401 35001750087429... |
correct output |
---|
2857
500024974229 1 5 9 13 17 21 25... |
user output |
---|
99 1740324137 754 752 2128 1679 1... Truncated |
Test 56
Group: 5
Verdict: WRONG ANSWER
input |
---|
2000 1000
499999999999833 50000000000035... |
correct output |
---|
1955
1 1 2 4 6 8 11 13 15 17 19 21 ... |
user output |
---|
12 1382236160 1880 1070 564 240 9... Truncated |