QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#534180#5280. Depot RearrangementMarSer020100 ✓32ms25400kbC++231.1kb2024-08-26 21:40:352024-08-26 21:40:36

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 0ms
memory: 3584kb

input:

10 3
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3


output:

0

result:

ok both subtasks are correct!

Test #2:

score: 5
Accepted
time: 0ms
memory: 3564kb

input:

5 4
1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4


output:

13
6 21
11 6
1 11
13 1
2 13
17 2
7 17
18 7
14 18
9 14
19 9
3 19
21 3

result:

ok both subtasks are correct!

Test #3:

score: 5
Accepted
time: 0ms
memory: 3636kb

input:

10 10
8 10 10 3 7 3 5 6 1 4 3 8 2 9 1 8 4 2 7 3 10 7 9 2 1 10 10 9 1 2 9 7 4 5 2 9 10 5 7 6 6 8 6 8 4 2 9 1 2 8 6 1 4 2 2 1 5 6 3 10 10 7 9 4 8 9 8 2 5 6 4 3 1 6 3 3 10 7 7 5 3 6 8 5 9 4 6 7 9 4 10 5 3 4 5 1 1 7 8 5


output:

32
13 101
34 13
25 34
4 25
23 4
86 23
52 86
32 52
11 32
41 11
72 41
24 72
92 24
46 92
95 46
51 95
12 51
21 12
82 21
54 82
31 54
42 31
78 42
44 78
26 44
65 26
96 65
63 96
75 63
85 75
2 85
101 2

result:

ok both subtasks are correct!

Test #4:

score: 5
Accepted
time: 0ms
memory: 3720kb

input:

100 10
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 9 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10...

output:

19
451 1001
183 451
733 183
711 733
811 711
202 811
825 202
172 825
772 172
665 772
844 665
812 844
352 812
942 352
101 942
1001 101
746 1001
706 746
1001 706

result:

ok both subtasks are correct!

Test #5:

score: 5
Accepted
time: 1ms
memory: 3760kb

input:

200 100
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...

output:

195
5768 20001
6543 5768
17137 6543
8933 17137
5833 8933
3716 5833
4216 3716
11233 4216
19177 11233
7614 19177
2001 7614
16301 2001
12708 16301
6329 12708
12729 6329
7922 12729
13422 7922
19312 13422
13412 19312
11608 13412
18908 11608
16308 18908
13107 16308
6807 13107
5914 6807
14914 5914
625 1491...

result:

ok both subtasks are correct!

Test #6:

score: 5
Accepted
time: 1ms
memory: 3892kb

input:

201 20
20 18 5 5 1 7 8 17 12 10 20 12 13 19 16 2 9 8 20 20 19 10 17 20 9 11 15 17 9 2 3 4 17 10 7 20 7 19 17 11 20 2 1 13 11 9 11 6 10 8 11 3 2 16 9 15 16 12 13 6 5 13 4 13 3 8 20 18 10 3 14 1 11 20 17 17 2 11 20 1 4 10 3 3 9 13 7 10 19 16 14 16 9 19 14 15 12 9 20 12 2 19 18 2 7 7 2 12 10 8 20 18 16...

output:

1401
65 4021
48 65
138 48
72 138
35 72
143 35
83 143
144 83
7 144
224 7
105 224
227 105
9 227
148 9
26 148
3 26
45 3
142 45
44 142
106 44
244 106
123 244
150 123
91 150
42 91
327 42
101 327
167 101
249 167
25 249
261 25
356 261
104 356
62 104
46 62
23 46
170 23
289 170
274 289
328 274
308 328
367 30...

result:

ok both subtasks are correct!

Test #7:

score: 5
Accepted
time: 4ms
memory: 4100kb

input:

300 300
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...

output:

205
72627 90001
75609 72627
72609 75609
11765 72609
72665 11765
81629 72665
44729 81629
53318 44729
26318 53318
16718 26318
17416 16718
80416 17416
65716 80416
58284 65716
3130 58284
77830 3130
20226 77830
21726 20226
65784 21726
16516 65784
30072 16516
15407 30072
49635 15407
15435 49635
5789 15435...

result:

ok both subtasks are correct!

Test #8:

score: 5
Accepted
time: 0ms
memory: 5804kb

input:

301 40
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

11624
302 12041
603 302
1 603
604 1
904 604
2 904
905 2
303 905
906 303
1206 906
3 1206
1207 3
304 1207
1208 304
605 1208
1209 605
1506 1209
4 1506
1507 4
305 1507
1508 305
606 1508
1509 606
907 1509
1510 907
1807 1510
5 1807
1808 5
306 1808
1809 306
607 1809
1810 607
908 1810
1811 908
1210 1811
181...

result:

ok both subtasks are correct!

Test #9:

score: 5
Accepted
time: 5ms
memory: 6500kb

input:

400 100
11 65 1 79 15 18 79 46 9 30 71 53 58 55 94 73 39 16 6 91 49 30 23 30 28 81 90 48 97 54 79 30 94 18 42 77 44 36 5 48 55 97 79 36 41 59 79 71 32 59 3 10 63 52 44 41 9 46 31 31 56 87 60 80 12 51 15 78 41 65 95 34 29 83 46 64 37 53 98 17 41 45 36 73 20 53 48 80 57 54 57 72 39 56 98 6 10 78 11 72...

output:

14592
149 40001
878 149
19 878
550 19
1518 550
220 1518
9 220
372 9
1571 372
735 1571
2012 735
740 2012
2323 740
3281 2323
242 3281
52 242
226 52
422 226
327 422
2335 327
223 2335
141 223
315 141
484 315
803 484
1 803
1164 1
337 1164
410 337
819 410
1368 819
345 1368
112 345
1038 112
3420 1038
1622 ...

result:

ok both subtasks are correct!

Test #10:

score: 5
Accepted
time: 1ms
memory: 3948kb

input:

40 160
17 2 3 4 5 6 7 91 9 10 154 12 103 14 15 16 17 25 19 58 21 8 23 24 52 26 27 58 120 105 50 55 104 32 35 36 37 38 45 10 41 42 43 44 45 71 47 48 49 34 140 52 53 54 115 44 28 58 59 60 61 62 63 64 132 66 67 68 69 70 71 69 24 74 75 76 77 133 79 80 81 82 100 84 31 86 87 88 100 90 91 92 93 94 95 96 97...

output:

1316
481 6401
644 481
2242 644
1444 2242
2722 1444
1286 2722
1448 1286
483 1448
10 483
331 10
9 331
702 9
1452 702
805 1452
2882 805
2724 2882
1928 2724
803 1928
1289 803
1614 1289
3682 1614
1921 3682
807 1921
175 807
3750 175
1 3750
1778 1
3804 1778
2258 3804
2725 2258
3374 2725
2401 3374
2088 2401...

result:

ok both subtasks are correct!

Test #11:

score: 5
Accepted
time: 5ms
memory: 6508kb

input:

400 100
88 82 9 2 90 1 83 32 32 79 8 79 63 67 85 82 50 63 69 2 7 91 21 90 69 3 39 78 66 83 96 53 24 65 56 63 90 54 35 55 94 22 76 12 54 55 5 49 91 73 8 19 64 54 39 23 13 27 34 4 81 52 13 11 36 45 3 50 82 81 42 50 75 15 99 70 29 26 70 66 34 15 42 83 16 19 19 12 76 1 68 49 7 17 64 37 98 34 99 37 34 64...

output:

14611
432 40001
4 432
739 4
6 739
911 6
129 911
501 129
26 501
307 26
922 307
11 922
626 11
590 626
136 590
937 136
529 937
456 529
652 456
532 652
1242 532
1026 1242
601 1026
925 601
362 925
1346 362
228 1346
949 228
57 949
109 57
955 109
239 955
1803 239
527 1803
21 527
110 21
1261 110
958 1261
56...

result:

ok both subtasks are correct!

Test #12:

score: 5
Accepted
time: 0ms
memory: 4504kb

input:

301 20
8 1 1 1 1 1 1 17 1 9 1 5 1 1 1 1 13 1 9 1 18 1 1 16 1 15 5 19 1 8 11 10 1 1 1 1 18 4 1 1 1 1 16 1 1 1 12 10 1 1 1 14 11 13 1 1 1 1 1 1 10 1 1 1 1 1 1 19 14 1 1 1 5 1 1 1 1 13 1 18 1 1 4 1 1 1 1 1 1 1 1 1 1 16 16 10 1 14 18 1 1 1 7 1 1 1 1 6 9 1 13 1 1 1 2 1 1 1 1 1 1 10 1 1 1 17 1 10 10 1 12 ...

output:

4260
226 6021
541 226
2 541
603 2
3 603
663 3
4 663
1432 4
5 1432
841 5
6 841
122 6
302 122
605 302
907 605
7 907
422 7
9 422
341 9
11 341
221 11
908 221
583 908
606 583
781 606
13 781
1741 13
14 1741
94 14
303 94
1506 303
15 1506
21 15
304 21
1807 304
305 1807
171 305
306 171
10 306
842 10
307 842
...

result:

ok both subtasks are correct!

Test #13:

score: 5
Accepted
time: 12ms
memory: 9604kb

input:

300 300
215 159 263 206 201 183 286 56 142 10 231 214 34 54 263 250 169 208 239 148 104 22 244 17 74 68 184 52 2 30 42 83 222 106 25 152 37 225 213 213 69 273 91 221 207 48 166 28 221 50 46 64 10 254 207 109 206 144 270 291 195 197 253 235 141 186 102 68 52 24 38 6 181 44 256 200 77 233 285 163 223 ...

output:

32648
942 90001
1804 942
3624 1804
302 3624
931 302
4714 931
10 4714
1896 10
152 1896
2105 152
4662 2105
127 4662
910 127
53 910
1514 53
3302 1514
4805 3302
1955 4805
3029 1955
974 3029
3685 974
2704 3685
5879 2704
5109 5879
6603 5109
3211 6603
3930 3211
6620 3930
2143 6620
5404 2143
1376 5404
4831 ...

result:

ok both subtasks are correct!

Test #14:

score: 5
Accepted
time: 6ms
memory: 15552kb

input:

201 400
1 1 1 1 1 152 1 1 1 1 1 1 1 33 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 300 154 1 1 147 1 1 1 383 186 1 1 90 256 1 1 1 1 1 1 1 63 1 1 1 1 208 1 1 1 1 31 1 1 1 1 1 1 1 127 1 1 29 216 397 393 1 1 1 1 1 1 279 1 1 1 1 55 1 1 215 249 1 1 1 1 1 1 172 1 1 1 1 1 1 1 1 1 1 1 1 349 1 331 1 1 1 1 1 1 1 34...

output:

63990
403 80401
1 403
414 1
806 414
2 806
809 2
404 809
1207 404
3 1207
1208 3
202 1208
1409 202
405 1409
1410 405
606 1410
1609 606
4 1609
1610 4
203 1610
1810 203
406 1810
1811 406
608 1811
2011 608
5 2011
2012 5
204 2012
2213 204
408 2213
2215 408
609 2215
2409 609
7 2409
2416 7
409 2416
3017 409...

result:

ok both subtasks are correct!

Test #15:

score: 5
Accepted
time: 6ms
memory: 4352kb

input:

400 400
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...

output:

217
118632 160001
632 118632
160001 632
11717 160001
2917 11717
147420 2917
133336 147420
87309 133336
132079 87309
12879 132079
48896 12879
95203 48896
98003 95203
148290 98003
112690 148290
52496 112690
29615 52496
42015 29615
40418 42015
87618 40418
38828 87618
55219 38828
38819 55219
145818 3881...

result:

ok both subtasks are correct!

Test #16:

score: 5
Accepted
time: 6ms
memory: 8000kb

input:

301 200
50 129 146 60 183 51 47 77 26 73 1 45 1 44 149 1 81 196 17 16 163 35 159 71 1 94 161 138 138 27 76 1 102 42 5 186 176 1 111 198 37 63 81 155 95 164 132 135 155 194 126 98 31 34 121 19 175 148 33 105 25 122 91 165 1 69 1 197 12 98 1 155 5 53 42 1 60 98 78 61 155 13 1 171 102 152 95 61 87 200 ...

output:

23506
442 60201
139 442
426 139
35 426
478 35
1318 478
11 1318
814 11
518 814
248 518
617 248
13 617
817 13
213 817
905 213
56 905
406 56
82 406
245 82
696 245
1020 696
1650 1020
216 1650
20 216
675 20
1808 675
621 1808
2101 621
633 2101
316 633
659 316
69 659
760 69
227 760
1022 227
2683 1022
311 2...

result:

ok both subtasks are correct!

Test #17:

score: 5
Accepted
time: 16ms
memory: 18532kb

input:

201 400
1 1 1 1 1 1 1 1 1 1 1 1 1 263 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 246 1 1 1 1 1 1 1 1 1 1 1 1 1 1 107 1 1 1 1 1 1 1 1 57 1 1 1 1 1 1 1 224 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 90 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

77869
604 80401
1006 604
1 1006
805 1
202 805
1007 202
403 1007
1207 403
2 1207
1208 2
203 1208
1408 203
404 1408
1409 404
605 1409
1609 605
3 1609
1610 3
204 1610
1601 204
405 1601
1810 405
606 1810
2011 606
4 2011
2012 4
205 2012
2212 205
406 2212
2213 406
607 2213
2413 607
5 2413
2414 5
206 2414
...

result:

ok both subtasks are correct!

Test #18:

score: 5
Accepted
time: 12ms
memory: 11936kb

input:

400 300
75 26 289 176 131 196 124 8 230 157 247 265 13 2 210 141 17 200 187 83 21 22 118 144 232 26 284 75 48 30 132 32 65 34 72 36 73 286 164 40 41 261 65 270 221 12 139 48 49 143 91 39 17 258 275 56 151 194 282 55 228 266 296 64 22 232 67 142 69 152 10 102 109 45 75 49 283 112 78 283 81 236 169 22...

output:

43105
932 120001
692 932
223 692
4503 223
304 4503
1006 304
4511 1006
1505 4511
4803 1505
14 4803
392 14
685 392
161 685
2186 161
2402 2186
6303 2402
5115 6303
4063 5115
8432 4063
2101 8432
8546 2101
5431 8546
2438 5431
762 2438
594 762
9445 594
2863 9445
9603 2863
3359 9603
4726 3359
355 4726
5527 ...

result:

ok both subtasks are correct!

Test #19:

score: 5
Accepted
time: 32ms
memory: 25400kb

input:

333 399
1 1 1 1 1 1 1 28 1 1 1 1 1 1 161 1 17 1 1 1 1 262 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 43 1 1 1 1 1 70 1 1 1 142 1 1 1 1 1 1 1 1 1 1 1 1 70 1 1 1 1 1 1 278 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 245 1 1 1 1 1 1 33 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 106 1 1 1 1 268 1 1 1 172 1 1 1 1 1 312 1 286 1 1 1 1 ...

output:

114795
1001 132868
334 1001
1298 334
1 1298
1666 1
2 1666
1999 2
3 1999
2332 3
335 2332
2665 335
4 2665
2998 4
5 2998
3331 5
6 3331
3665 6
7 3665
3997 7
9 3997
4330 9
336 4330
4663 336
10 4663
4996 10
11 4996
5663 11
12 5663
6328 12
337 6328
6661 337
13 6661
6994 13
14 6994
7327 14
338 7327
7661 338...

result:

ok both subtasks are correct!

Test #20:

score: 5
Accepted
time: 23ms
memory: 14704kb

input:

400 400
100 35 353 385 317 228 7 148 113 165 11 306 209 89 21 166 17 2 19 249 27 305 377 22 3 353 38 28 29 96 191 32 33 309 35 308 100 176 152 40 176 42 43 86 45 46 96 48 396 381 218 246 53 54 334 159 243 360 294 60 33 62 185 64 65 66 191 121 351 107 10 343 367 74 75 201 77 247 79 134 304 92 42 126 ...

output:

55816
801 160001
25 801
406 25
1642 406
18 1642
1566 18
813 1566
215 813
413 215
147 413
2014 147
802 2014
3209 802
920 3209
11 920
3738 11
3202 3738
473 3202
1222 473
405 1222
4404 405
4227 4404
2001 4227
7031 2001
2403 7031
5201 2403
2401 5201
1606 2401
2670 1606
690 2670
71 690
633 71
24 633
420 ...

result:

ok both subtasks are correct!