QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#691887#5280. Depot RearrangementMilmon95 25ms18176kbC++201.3kb2024-10-31 13:19:402024-10-31 13:19:49

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

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

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: 1ms
memory: 3836kb

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
8 21
12 8
4 12
15 4
3 15
20 3
7 20
19 7
14 19
10 14
18 10
2 18
21 2

result:

ok both subtasks are correct!

Test #3:

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

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
18 101
38 18
29 38
6 29
28 6
90 28
56 90
39 56
20 39
43 20
76 43
30 76
100 30
49 100
95 49
58 95
16 58
27 16
87 27
55 87
36 55
50 36
79 50
44 79
26 44
67 26
97 67
66 97
75 66
89 75
3 89
101 3

result:

ok both subtasks are correct!

Test #4:

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

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
453 1001
184 453
734 184
713 734
819 713
210 819
830 210
175 830
775 175
670 775
850 670
814 850
359 814
949 359
109 949
1001 109
747 1001
707 747
1001 707

result:

ok both subtasks are correct!

Test #5:

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

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
5773 20001
6579 5773
17199 6579
8977 17199
5861 8977
3761 5861
4233 3761
11277 4233
19198 11277
7667 19198
2067 7667
16367 2067
12753 16367
6330 12753
12730 6330
7953 12730
13453 7953
19380 13453
13480 19380
11653 13480
18966 11653
16366 18966
13167 16366
6867 13167
5967 6867
14925 5967
696 1492...

result:

ok both subtasks are correct!

Test #6:

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

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
70 4021
60 70
140 60
80 140
37 80
155 37
84 155
144 84
18 144
239 18
119 239
231 119
12 231
153 12
40 153
4 40
51 4
149 51
59 149
106 59
255 106
129 255
150 129
95 150
53 95
340 53
107 340
178 107
258 178
29 258
269 29
358 269
104 358
64 104
55 64
39 55
180 39
296 180
280 296
331 280
313 331
38...

result:

ok both subtasks are correct!

Test #7:

score: 5
Accepted
time: 10ms
memory: 10192kb

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
72662 90001
75733 72662
72733 75733
11820 72733
72720 11820
81662 72720
44971 81662
53371 44971
26373 53371
16773 26373
17623 16773
80623 17623
65885 80623
58459 65885
3259 58459
77959 3259
20359 77959
21859 20359
65959 21859
16685 65959
30110 16685
15410 30110
49695 15410
15495 49695
5807 15495...

result:

ok both subtasks are correct!

Test #8:

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

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
320 12041
640 320
40 640
639 40
920 639
39 920
919 39
319 919
918 319
1240 918
38 1240
1239 38
318 1239
1238 318
638 1238
1237 638
1520 1237
37 1520
1519 37
317 1519
1518 317
637 1518
1517 637
917 1517
1516 917
1840 1516
36 1840
1839 36
316 1839
1838 316
636 1838
1837 636
916 1837
1836 916
123...

result:

ok both subtasks are correct!

Test #9:

score: 5
Accepted
time: 8ms
memory: 9888kb

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
196 40001
900 196
96 900
600 96
1593 600
249 1593
57 249
395 57
1571 395
777 1571
2037 777
740 2037
2388 740
3285 2388
242 3285
97 242
281 97
482 281
381 482
2362 381
287 2362
158 287
400 158
489 400
888 489
99 888
1193 99
345 1193
480 345
889 480
1369 889
337 1369
163 337
1066 163
3436 1066
1...

result:

ok both subtasks are correct!

Test #10:

score: 5
Accepted
time: 2ms
memory: 4516kb

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
510 6401
750 510
2337 750
1581 2337
2805 1581
1428 2805
1560 1428
534 1560
40 534
338 40
137 338
757 137
1485 757
839 1485
2906 839
2873 2906
2065 2873
806 2065
1366 806
1631 1366
3835 1631
2009 3835
938 2009
182 938
3804 182
17 3804
1876 17
3750 1876
2308 3750
2819 2308
3453 2819
2417 3453
223...

result:

ok both subtasks are correct!

Test #11:

score: 5
Accepted
time: 9ms
memory: 9632kb

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
495 40001
20 495
763 20
90 763
996 90
170 996
577 170
67 577
311 67
987 311
51 987
643 51
592 643
159 592
953 159
595 953
483 595
659 483
532 659
1274 532
1097 1274
690 1097
988 690
397 988
1362 397
253 1362
949 253
63 949
132 63
955 132
264 955
1825 264
558 1825
93 558
134 93
1298 134
976 129...

result:

ok both subtasks are correct!

Test #12:

score: 5
Accepted
time: 3ms
memory: 7712kb

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
239 6021
545 239
20 545
619 20
18 619
678 18
16 678
1435 16
15 1435
852 15
14 852
129 14
317 129
618 317
920 618
13 920
440 13
11 440
359 11
9 359
230 9
919 230
598 919
617 598
789 617
7 789
1760 7
6 1760
95 6
315 95
1520 315
5 1520
37 5
314 37
1820 314
312 1820
174 312
311 174
19 311
843 19
31...

result:

ok both subtasks are correct!

Test #13:

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

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
1094 90001
2020 1094
3698 2020
597 3698
1014 597
4750 1014
100 4750
1955 100
231 1955
2183 231
4748 2183
218 4748
1121 218
53 1121
1710 53
3454 1710
4975 3454
1896 4975
3228 1896
974 3228
3809 974
2932 3809
5950 2932
5337 5950
6676 5337
3211 6676
4190 3211
6620 4190
2267 6620
5664 2267
1458 56...

result:

ok both subtasks are correct!

Test #14:

score: 5
Accepted
time: 10ms
memory: 16088kb

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
689 80401
201 689
800 201
1004 800
200 1004
1003 200
603 1003
1406 603
199 1406
1405 199
397 1405
1600 397
602 1600
1599 602
799 1599
1809 799
197 1809
1808 197
396 1808
2000 396
599 2000
1999 599
797 1999
2211 797
196 2211
2209 196
395 2209
2400 395
598 2400
2399 598
796 2399
2612 796
195 261...

result:

ok both subtasks are correct!

Test #15:

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

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
118784 160001
784 118784
160001 784
11722 160001
2922 11722
147572 2922
133420 147572
87336 133420
132109 87336
12909 132109
49143 12909
95543 49143
98343 95543
148343 98343
112743 148343
52743 112743
29909 52743
42309 29909
40709 42309
87909 40709
39109 87909
55390 39109
38990 55390
145870 3899...

result:

ok both subtasks are correct!

Test #16:

score: 5
Accepted
time: 8ms
memory: 11896kb

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
532 60201
165 532
505 165
73 505
528 73
1356 528
134 1356
875 134
518 875
325 518
793 325
109 793
888 109
221 888
988 221
106 988
471 106
200 471
384 200
702 384
1090 702
1778 1090
396 1778
187 396
728 187
1987 728
766 1987
2194 766
759 2194
316 759
706 316
94 706
780 94
276 780
1147 276
2771 ...

result:

ok both subtasks are correct!

Test #17:

score: 5
Accepted
time: 7ms
memory: 15608kb

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
800 80401
1200 800
201 1200
1005 201
400 1005
1199 400
603 1199
1407 603
200 1407
1406 200
399 1406
1600 399
602 1600
1599 602
799 1599
1809 799
199 1809
1808 199
398 1808
2000 398
601 2000
1999 601
798 1999
2211 798
198 2211
2210 198
397 2210
2400 397
600 2400
2399 600
797 2399
2613 797
197 2...

result:

ok both subtasks are correct!

Test #18:

score: 5
Accepted
time: 21ms
memory: 16004kb

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
1139 120001
775 1139
253 775
4679 253
427 4679
1006 427
4766 1006
1692 4766
5011 1692
124 5011
392 124
690 392
243 690
2390 243
2450 2390
6592 2450
5395 6592
4136 5395
8696 4136
2215 8696
8546 2215
5643 8546
2642 5643
873 2642
600 873
9516 600
2865 9516
9717 2865
3543 9717
4726 3543
421 4726
5...

result:

ok both subtasks are correct!

Test #19:

score: 0
Runtime Error

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:


result:


Test #20:

score: 5
Accepted
time: 25ms
memory: 18176kb

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
1074 160001
287 1074
546 287
1984 546
391 1984
1580 391
1033 1580
323 1033
496 323
147 496
2356 147
1162 2356
3547 1162
920 3547
94 920
3926 94
3365 3926
776 3365
1228 776
569 1228
4567 569
4380 4567
2388 4380
7049 2388
2738 7049
5423 2738
2676 5423
1901 2676
2670 1901
690 2670
328 690
694 328...

result:

ok both subtasks are correct!