QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#877697#9070. Candy FactoryZhangYiDeAC ✓1ms3840kbC++20467b2025-02-01 00:56:332025-02-01 00:56:33

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 3
1
3
4
1

output:

3

result:

ok single line: '3'

Test #2:

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

input:

4 4
1
3
4
1

output:

7

result:

ok single line: '7'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

4 2
1
3
4
1

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

6 3
5
5
5
3
1
1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

5 4
5
4
3
2
1

output:

5

result:

ok single line: '5'

Test #6:

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

input:

2 2
100
50

output:

50

result:

ok single line: '50'

Test #7:

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

input:

6 4
100
100
100
50
50
50

output:

2

result:

ok single line: '2'

Test #8:

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

input:

7 6
1
5
6
6
6
6
7

output:

5

result:

ok single line: '5'

Test #9:

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

input:

7 6
1
5
5
6
6
6
7

output:

6

result:

ok single line: '6'

Test #10:

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

input:

7 6
1
4
5
6
6
6
7

output:

7

result:

ok single line: '7'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

5000 5000
1000000000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

4998999995001

result:

ok single line: '4998999995001'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

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

output:

1

result:

ok single line: '1'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

3

result:

ok single line: '3'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

5000 137
40
40
41
7
27
22
14
30
4
26
6
22
3
33
43
6
27
18
14
2
46
46
17
47
32
5
4
7
23
28
31
27
20
13
11
48
32
46
31
37
37
48
12
15
23
11
30
37
4
10
5
20
46
43
14
16
23
5
16
5
29
35
40
18
18
30
50
48
24
42
18
15
39
23
28
34
43
26
44
36
47
37
48
33
17
41
27
50
49
5
47
15
26
3
31
31
14
6
24
18
20
4
46...

output:

34

result:

ok single line: '34'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

5000 621
17
7
15
6
17
13
44
44
34
9
17
15
20
19
22
29
28
21
43
24
4
32
39
49
2
36
13
48
36
45
13
17
34
26
12
29
1
13
50
35
4
25
20
5
6
30
21
20
26
34
18
4
38
7
19
3
20
42
49
2
8
31
6
4
39
23
40
42
9
1
19
29
28
29
6
47
31
36
6
50
40
15
19
3
21
7
12
42
30
33
25
15
49
49
39
9
5
8
30
42
47
27
4
43
48
31...

output:

263

result:

ok single line: '263'

Test #16:

score: 0
Accepted
time: 1ms
memory: 3840kb

input:

5000 2548
5
4
16
34
6
22
33
14
27
41
21
32
23
38
18
17
12
17
34
27
39
48
23
21
29
49
27
33
28
19
7
43
19
26
1
2
13
15
9
9
29
41
42
30
27
6
16
42
32
21
6
25
11
46
6
44
19
40
3
4
31
19
50
14
32
41
21
33
24
40
41
20
3
26
17
45
6
25
33
39
30
28
46
44
3
35
43
13
45
9
39
46
32
17
18
34
24
17
27
9
45
47
33...

output:

90

result:

ok single line: '90'

Test #17:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

5000 4276
26
26
32
32
25
12
38
19
24
36
24
45
10
24
29
6
18
45
18
38
42
8
45
32
4
24
11
22
35
27
27
29
38
32
4
26
31
34
43
2
9
46
43
15
12
9
24
31
41
11
24
49
26
38
1
34
4
22
39
22
8
26
41
11
28
14
26
36
17
9
42
15
50
27
17
9
7
24
41
3
11
44
46
10
48
40
28
45
29
5
31
12
50
15
17
43
18
24
3
47
30
29
...

output:

85933

result:

ok single line: '85933'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3840kb

input:

5000 2
491692224
465461918
633893589
234388088
140842638
312990555
460928848
105968808
604122527
123080145
312065793
554735673
244064573
648460749
399871829
869116078
264645154
542519368
91784000
765807220
222778886
833504276
651880147
571326150
182056966
676142473
130510618
590642938
168899991
5279...

output:

1

result:

ok single line: '1'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

5000 7
523444485
806641326
446992117
561823955
222034406
445583647
902196446
646651730
533925124
607752031
423951959
473010209
972070639
197930493
760872780
565261716
966292063
333847626
310370999
507615121
492128916
500953052
229923734
280916675
372566666
428520015
784893149
252665196
828300854
753...

output:

3

result:

ok single line: '3'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

5000 265
200222948
763440905
109114196
831256633
815178667
166948060
517763355
594099787
561671404
17063151
161027550
930268123
938151114
824924195
287482387
831885606
728429551
649505989
742952156
671148735
121320550
673016988
77001290
808704459
128623936
714680687
799868776
127726852
41074241
1655...

output:

93

result:

ok single line: '93'

Test #21:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

5000 1375
582608842
927863532
439434259
412674554
270162334
528722538
908221930
779214773
509731520
352908012
306584077
29621789
42331670
159866305
502831381
912872439
410071617
635626443
625730327
647953198
419224105
286951009
625682418
185487195
301689833
902947553
937570093
397804304
297218662
29...

output:

110

result:

ok single line: '110'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

5000 3897
411980978
83716563
932241457
274977328
269723405
642375790
778060129
865227208
344650659
414360590
889345172
117246219
391502763
561379904
159948671
339028094
99985020
826149495
313626420
338941764
403632524
992885381
382591112
485427971
120652336
593436712
201269729
281638288
642474404
97...

output:

1392360598236

result:

ok single line: '1392360598236'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

5000 4933
871983359
71819434
640271641
117851189
843900190
514783193
172634566
326734120
44517402
63712020
846952613
874700920
206323748
350038962
359320895
215631121
911149897
914841429
799739865
57634166
239684682
609394344
524629151
884745415
635913206
416993069
71482403
483362682
244516601
93622...

output:

2403937756501

result:

ok single line: '2403937756501'

Test #24:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

5000 2
1000000000
999999999
999999998
999999997
999999996
999999995
999999994
999999993
999999992
999999991
999999990
999999989
999999988
999999987
999999986
999999985
999999984
999999983
999999982
999999981
999999980
999999979
999999978
999999977
999999976
999999975
999999974
999999973
999999972
99...

output:

0

result:

ok single line: '0'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

5000 2
1000000000
999999999
999999998
999999996
999999993
999999990
999999988
999999986
999999985
999999984
999999982
999999979
999999978
999999977
999999975
999999973
999999972
999999970
999999969
999999967
999999965
999999964
999999961
999999960
999999957
999999955
999999952
999999951
999999950
99...

output:

1

result:

ok single line: '1'

Test #26:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

5000 2
1000000000
999999168
999998515
999998216
999997948
999997664
999997371
999997369
999996723
999996346
999995364
999994420
999994378
999994065
999993164
999992603
999992366
999991917
999990987
999990570
999989935
999988978
999988144
999987369
999987358
999987222
999986644
999985863
999985422
99...

output:

0

result:

ok single line: '0'

Test #27:

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

input:

5000 7
1000000000
999999999
999999998
999999997
999999996
999999995
999999994
999999993
999999992
999999991
999999990
999999989
999999988
999999987
999999986
999999985
999999984
999999983
999999982
999999981
999999980
999999979
999999978
999999977
999999976
999999975
999999974
999999973
999999972
99...

output:

3

result:

ok single line: '3'

Test #28:

score: 0
Accepted
time: 1ms
memory: 3840kb

input:

5000 2500
1000000000
999999999
999999998
999999997
999999996
999999995
999999994
999999993
999999992
999999991
999999990
999999989
999999988
999999987
999999986
999999985
999999984
999999983
999999982
999999981
999999980
999999979
999999978
999999977
999999976
999999975
999999974
999999973
999999972...

output:

0

result:

ok single line: '0'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

5000 7
1000000000
999999998
999999996
999999993
999999991
999999988
999999986
999999983
999999982
999999981
999999980
999999977
999999974
999999972
999999971
999999970
999999967
999999966
999999965
999999962
999999959
999999958
999999957
999999956
999999955
999999952
999999951
999999950
999999948
99...

output:

2

result:

ok single line: '2'

Test #30:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

5000 2500
1000000000
999999997
999999996
999999993
999999990
999999987
999999984
999999981
999999978
999999977
999999974
999999973
999999971
999999969
999999966
999999963
999999962
999999959
999999957
999999956
999999954
999999951
999999949
999999947
999999945
999999944
999999941
999999939
999999938...

output:

632

result:

ok single line: '632'

Test #31:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

5000 7
1000000000
999999020
999998656
999997658
999996869
999996689
999996594
999996480
999995779
999994878
999994234
999994043
999993477
999992787
999991899
999991011
999990042
999989481
999989314
999988969
999988624
999987814
999987216
999986771
999986610
999986249
999985732
999985566
999985327
99...

output:

6

result:

ok single line: '6'

Test #32:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

5000 2500
1000000000
999999716
999999293
999998978
999998247
999997503
999996607
999996186
999995445
999995315
999995115
999994923
999994250
999993750
999993484
999992978
999992536
999992185
999991693
999991222
999990271
999989685
999989543
999989208
999989162
999988303
999988027
999987388
999987309...

output:

191

result:

ok single line: '191'

Test #33:

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

input:

1 1
1000000000

output:

0

result:

ok single line: '0'

Test #34:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

1 1
1

output:

0

result:

ok single line: '0'