QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#790610#9058. Range EditingdXqwq#AC ✓81ms8884kbC++231.2kb2024-11-28 13:59:122024-11-28 13:59:12

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

10
0
1
2
3
4
2
1
0
0
1

output:

5

result:

ok single line: '5'

Test #2:

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

input:

1
777

output:

1

result:

ok single line: '1'

Test #3:

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

input:

3
0
0
0

output:

0

result:

ok single line: '0'

Test #4:

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

input:

8
0
0
1
0
0
2
0
0

output:

2

result:

ok single line: '2'

Test #5:

score: 0
Accepted
time: 19ms
memory: 8416kb

input:

800
1
1
1
1
1
1
0
1
1
1
1
0
1
1
0
0
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
1
1
0
1
1
1
1
0
1
0
1
1
1
1
0
0
1
1
1
0
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1
1
0
1
1
1
1
1
1
0
1
1
0
1
1
1
1
...

output:

81

result:

ok single line: '81'

Test #6:

score: 0
Accepted
time: 51ms
memory: 8472kb

input:

800
2
1
1
2
2
1
2
1
0
2
0
1
1
2
2
2
2
2
1
0
2
2
1
2
2
2
2
1
2
1
1
2
2
1
1
2
2
1
1
1
1
2
2
1
2
1
1
0
0
2
1
2
1
2
2
2
1
2
1
2
1
1
2
2
1
1
0
2
1
1
1
1
1
1
1
2
1
1
2
1
1
2
1
2
1
1
1
2
1
1
2
1
1
2
0
0
1
2
1
1
2
2
1
0
1
2
1
2
2
1
2
0
2
1
0
1
2
1
2
2
0
2
1
2
2
1
1
2
2
1
1
2
1
0
2
1
1
0
1
0
1
2
1
1
1
1
1
2
...

output:

244

result:

ok single line: '244'

Test #7:

score: 0
Accepted
time: 54ms
memory: 8784kb

input:

800
2
3
0
3
1
1
3
2
1
2
3
3
3
1
1
2
3
2
2
3
1
2
1
2
1
3
3
1
3
3
3
0
1
3
3
1
3
2
3
0
1
3
0
1
2
3
1
3
2
3
2
2
1
0
1
3
1
0
3
0
1
0
2
1
2
2
1
1
1
3
2
3
3
2
2
2
2
3
1
2
3
1
0
3
2
2
2
2
2
3
2
1
1
2
2
3
3
3
3
3
0
2
3
1
2
1
3
1
3
2
1
1
3
1
3
1
3
3
1
2
3
0
2
3
2
3
2
2
2
2
1
1
3
3
2
2
0
3
3
2
3
1
3
1
2
1
3
2
...

output:

303

result:

ok single line: '303'

Test #8:

score: 0
Accepted
time: 69ms
memory: 8592kb

input:

800
2
5
0
1
0
5
4
5
2
3
3
1
5
3
1
2
2
0
1
3
3
3
2
4
1
4
3
3
2
4
0
4
2
3
4
5
2
4
2
1
3
2
2
1
1
3
2
0
1
4
3
3
5
1
3
0
3
1
4
1
5
0
3
5
0
2
1
3
3
3
2
4
4
2
1
3
5
1
5
0
5
1
0
4
3
2
2
5
4
4
2
0
1
1
2
2
5
3
1
0
5
4
5
1
2
3
3
3
2
1
1
0
5
3
2
0
5
1
3
4
3
3
4
2
2
5
5
1
3
2
3
5
2
1
1
4
5
2
3
4
4
2
1
3
3
2
1
5
...

output:

375

result:

ok single line: '375'

Test #9:

score: 0
Accepted
time: 72ms
memory: 8592kb

input:

800
3
3
7
5
7
6
0
5
2
0
4
0
5
6
1
7
7
7
5
5
7
5
0
2
7
2
2
6
1
4
0
6
5
6
6
6
7
2
4
2
6
7
5
2
4
1
3
7
4
0
7
2
6
6
2
6
4
1
2
5
5
7
4
7
3
6
3
1
7
4
1
0
5
6
5
2
0
1
4
7
0
5
1
0
2
4
2
1
7
0
6
0
6
7
6
2
7
4
6
0
5
4
1
2
2
6
6
2
7
2
4
5
3
4
2
0
7
1
4
0
1
5
2
3
7
3
2
4
1
4
4
5
2
2
7
0
2
6
0
5
5
5
1
3
6
1
7
4
...

output:

416

result:

ok single line: '416'

Test #10:

score: 0
Accepted
time: 72ms
memory: 8624kb

input:

800
7
2
9
6
7
3
2
10
0
8
8
2
2
10
5
5
5
10
10
10
10
0
4
0
7
6
6
3
2
3
6
9
7
2
4
7
9
5
8
7
6
9
4
6
6
1
5
5
3
6
4
1
2
9
7
10
5
3
6
5
1
5
1
6
8
10
7
3
0
2
1
7
4
0
3
6
0
4
5
9
2
7
8
1
2
10
10
5
10
10
3
2
8
6
2
0
6
1
2
3
6
10
0
10
0
6
0
5
0
4
4
9
5
2
5
0
2
0
10
7
6
8
1
9
0
3
1
2
4
7
6
6
5
3
7
6
2
5
1
0
8...

output:

464

result:

ok single line: '464'

Test #11:

score: 0
Accepted
time: 79ms
memory: 8568kb

input:

800
46
0
35
9
20
50
13
30
35
24
31
16
0
13
41
9
0
37
30
7
41
7
38
17
21
11
40
19
6
37
0
18
0
33
39
33
14
29
0
0
0
32
50
22
24
2
50
35
29
12
41
27
38
3
29
49
37
47
43
24
0
25
7
31
43
50
43
24
0
20
35
8
39
46
42
15
0
49
46
43
0
0
25
10
0
7
7
43
10
33
2
0
13
41
39
34
39
22
1
0
27
48
13
2
50
48
1
0
33
3...

output:

602

result:

ok single line: '602'

Test #12:

score: 0
Accepted
time: 77ms
memory: 8536kb

input:

800
118
235
144
28
285
90
79
282
0
274
36
186
0
148
224
245
118
107
6
0
215
141
0
56
71
58
83
5
291
0
94
215
129
0
154
163
0
97
88
53
0
209
58
207
0
0
0
113
115
218
198
85
256
42
250
272
248
130
296
34
0
0
195
87
13
275
0
0
182
5
116
255
169
224
289
40
38
199
67
102
14
175
53
245
0
54
29
83
10
146
2...

output:

698

result:

ok single line: '698'

Test #13:

score: 0
Accepted
time: 76ms
memory: 8732kb

input:

800
86
45
16
115
323
446
43
102
36
339
102
63
166
49
369
386
143
475
0
400
405
166
367
411
412
197
9
0
62
305
493
31
18
470
146
340
143
202
8
139
397
490
439
397
377
487
117
0
169
292
236
0
394
60
150
336
213
22
286
428
407
231
170
416
0
0
266
388
296
364
155
3
310
55
472
198
0
183
324
8
485
63
483
...

output:

696

result:

ok single line: '696'

Test #14:

score: 0
Accepted
time: 77ms
memory: 8640kb

input:

800
308
655
228
111
95
367
147
552
56
458
421
694
263
686
411
593
73
689
762
56
363
188
720
534
525
342
482
745
394
195
0
328
467
151
588
303
205
733
193
0
538
476
402
25
184
23
491
128
213
296
662
22
64
511
256
201
243
706
426
330
736
794
618
0
266
16
140
576
705
639
60
621
754
550
533
127
569
304
...

output:

706

result:

ok single line: '706'

Test #15:

score: 0
Accepted
time: 77ms
memory: 8648kb

input:

800
913270
373561
533461
0
5102
383215
61767
212831
906362
531267
806141
731940
0
146696
202757
848820
0
0
608835
839017
493366
816400
374381
484680
980158
149154
809469
0
511688
560286
593996
0
0
933338
107452
968709
265896
227849
744301
946204
532135
512383
816113
929887
388369
211914
766278
77416...

output:

712

result:

ok single line: '712'

Test #16:

score: 0
Accepted
time: 81ms
memory: 8520kb

input:

800
635885009
138430372
785972162
621909891
330984245
32124549
445385721
183219981
692358125
0
542331548
391701160
763931188
737334593
372017003
244827482
474535746
672357678
709983138
914702256
555552578
0
899679555
875443808
121797146
617019316
842514453
14935304
562710294
87399622
161880335
74796...

output:

721

result:

ok single line: '721'

Test #17:

score: 0
Accepted
time: 28ms
memory: 8716kb

input:

800
0
0
0
1
0
0
0
0
0
0
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
1
0
1
0
0
0
1
1
1
0
0
1
1
0
0
0
0
1
1
0
0
0
0
0
0
1
1
0
0
0
0
0
0
1
0
1
0
0
0
1
0
0
1
1
0
0
0
0
0
1
0
0
0
0
1
1
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
0
0
0
0
0
1
1
0
0
0
0
1
0
0
1
0
0
0
1
0
...

output:

147

result:

ok single line: '147'

Test #18:

score: 0
Accepted
time: 35ms
memory: 8820kb

input:

800
0
0
1
0
0
0
0
1
1
0
0
2
2
1
0
0
1
0
0
1
2
1
2
0
0
0
0
0
1
1
1
0
0
1
0
0
1
1
0
1
0
2
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
2
0
0
2
0
0
0
0
1
2
0
0
0
1
0
0
0
0
0
0
2
0
0
0
0
0
0
0
2
0
0
2
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
2
0
2
0
0
0
0
2
0
0
0
...

output:

164

result:

ok single line: '164'

Test #19:

score: 0
Accepted
time: 36ms
memory: 8728kb

input:

800
0
0
0
2
0
1
0
0
0
3
0
1
0
0
0
2
0
0
0
0
1
2
0
0
0
1
0
0
0
0
0
0
0
2
3
0
0
0
1
0
0
0
0
0
0
0
2
1
0
0
0
2
0
0
3
3
0
0
0
0
0
0
0
3
0
3
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
3
0
1
0
0
0
0
0
0
0
0
2
2
2
0
0
0
0
3
0
0
0
0
0
0
2
0
2
0
0
0
0
0
3
3
0
0
0
3
0
0
0
1
0
0
1
3
1
3
0
0
0
0
0
1
0
0
0
3
3
...

output:

171

result:

ok single line: '171'

Test #20:

score: 0
Accepted
time: 34ms
memory: 8500kb

input:

800
0
0
3
0
0
0
0
0
0
0
0
0
3
0
5
5
0
0
2
0
0
1
0
4
0
0
3
5
0
0
0
0
0
4
0
0
0
3
0
0
0
0
0
2
0
0
0
0
5
0
0
0
0
0
2
0
0
5
0
0
1
0
1
0
0
0
0
0
3
4
0
0
0
0
3
1
0
0
0
5
0
0
1
0
4
0
0
0
0
0
0
0
0
5
3
0
0
0
1
0
3
1
2
0
3
0
1
0
0
1
0
0
0
5
0
0
0
1
0
0
0
2
0
0
0
0
2
3
0
3
0
0
0
0
0
0
0
0
5
0
4
0
0
0
0
0
0
0
...

output:

169

result:

ok single line: '169'

Test #21:

score: 0
Accepted
time: 37ms
memory: 8584kb

input:

800
0
0
0
0
0
0
2
0
0
0
7
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
7
1
0
5
0
0
4
0
0
0
8
0
2
0
0
0
0
0
2
0
8
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
8
0
5
0
6
10
0
0
6
0
0
0
0
0
2
0
0
0
0
0
0
10
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
9
10
0
0
0
0
0
0
5
0
0
0
0
10
0
0
6
0
1
0
0
...

output:

173

result:

ok single line: '173'

Test #22:

score: 0
Accepted
time: 39ms
memory: 8488kb

input:

800
0
95
0
383
0
0
65
477
0
311
0
398
0
0
0
0
0
0
0
0
0
462
0
0
467
0
0
0
382
0
220
354
371
122
0
0
245
0
0
0
0
0
475
0
0
338
75
0
0
0
247
221
0
0
0
0
0
0
0
0
0
0
404
0
0
0
75
0
0
0
0
0
0
0
0
0
0
0
153
132
19
0
0
0
0
441
0
0
0
0
0
415
153
0
201
476
0
0
0
0
0
0
402
0
0
0
301
0
0
0
0
0
0
0
0
0
298
0
0...

output:

198

result:

ok single line: '198'

Test #23:

score: 0
Accepted
time: 33ms
memory: 8860kb

input:

800
0
0
0
0
0
406
0
0
0
752
0
0
0
0
511
0
0
0
761
0
635
0
190
0
742
201
0
0
0
131
0
0
0
283
0
312
0
0
0
233
0
0
0
133
0
0
0
86
0
303
0
0
110
0
0
0
190
530
385
0
0
533
551
0
0
0
120
0
0
649
0
0
0
0
0
0
0
0
281
0
0
632
0
0
0
0
223
0
0
0
0
113
0
0
0
0
0
797
0
0
36
0
0
0
0
68
135
274
0
29
62
0
0
0
0
0
0...

output:

191

result:

ok single line: '191'

Test #24:

score: 0
Accepted
time: 65ms
memory: 8512kb

input:

800
2
3
3
3
4
0
0
0
0
0
0
0
0
0
0
0
4
4
5
5
5
5
5
5
5
5
5
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5
5
5
5
5
5
5
5
5
5
5
5
5
5
2
2
2
2
2
2
2
2
1
1
1
0
0
0
2
2
2
2
5
5
5
5
5
5
5
5
5
5
4
4
4
4
4
4
4
4
4
4
4
4
4
5
5
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

output:

53

result:

ok single line: '53'

Test #25:

score: 0
Accepted
time: 71ms
memory: 8528kb

input:

800
29
23
3
3
0
0
38
38
38
38
38
38
38
38
38
38
38
38
38
38
38
38
38
38
38
38
38
40
48
48
48
48
48
48
48
48
48
48
46
46
46
46
46
46
46
46
46
46
0
0
0
0
0
0
0
0
41
41
41
41
41
41
41
38
38
38
38
41
41
41
41
39
39
39
39
39
39
39
39
39
39
39
39
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
24
24
24
24
24
24
2...

output:

43

result:

ok single line: '43'

Test #26:

score: 0
Accepted
time: 75ms
memory: 8772kb

input:

800
342
46
96
96
96
96
0
0
0
0
0
0
8
8
667
667
667
148
148
148
148
148
148
148
148
660
660
660
660
0
556
556
556
556
556
556
556
556
556
556
556
556
556
556
556
556
556
556
556
556
556
556
98
98
98
556
556
442
442
442
660
660
356
449
449
449
449
449
449
449
449
449
449
449
449
6
6
6
206
206
206
206
...

output:

59

result:

ok single line: '59'

Test #27:

score: 0
Accepted
time: 73ms
memory: 8764kb

input:

800
354828934
354828934
354828934
354828934
354828934
354828934
354828934
754064308
543897565
759297142
759297142
759297142
759297142
759297142
759297142
759297142
759297142
759297142
759297142
759297142
759297142
759297142
759297142
759297142
759297142
759297142
428511654
428511654
428511654
428511...

output:

50

result:

ok single line: '50'

Test #28:

score: 0
Accepted
time: 43ms
memory: 8536kb

input:

800
542090321
542090321
659296343
659296343
659296343
659296343
546605969
546605969
546605969
546605969
546605969
546605969
546605969
546605969
659296343
659296343
659296343
659296343
659296343
659296343
554024617
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
589159017
589159017
...

output:

23

result:

ok single line: '23'

Test #29:

score: 0
Accepted
time: 14ms
memory: 8648kb

input:

800
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
543011648
869943279
869943279
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

output:

17

result:

ok single line: '17'

Test #30:

score: 0
Accepted
time: 80ms
memory: 8508kb

input:

800
249236389
249236389
566060648
295954447
295954447
295954447
295954447
295954447
295954447
295954447
379052567
379052567
295954447
749796600
799801048
799801048
45263257
45263257
45263257
45263257
45263257
799801048
654343618
654343618
654343618
204916211
204916211
99536534
99536534
99536534
9953...

output:

203

result:

ok single line: '203'

Test #31:

score: 0
Accepted
time: 77ms
memory: 8536kb

input:

800
749329668
749329668
749329668
624862766
624862766
216564280
216564280
216564280
216564280
216564280
216564280
216564280
216564280
216564280
216564280
577554882
577554882
577554882
577554882
577554882
577554882
577554882
577554882
669574524
669574524
669574524
669574524
669574524
669574524
660771...

output:

183

result:

ok single line: '183'

Test #32:

score: 0
Accepted
time: 77ms
memory: 8648kb

input:

800
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
101
...

output:

800

result:

ok single line: '800'

Test #33:

score: 0
Accepted
time: 75ms
memory: 8884kb

input:

800
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
99999...

output:

800

result:

ok single line: '800'

Test #34:

score: 0
Accepted
time: 77ms
memory: 8504kb

input:

800
799000000
798000000
797000000
796000000
795000000
794000000
793000000
792000000
791000000
790000000
789000000
788000000
787000000
786000000
785000000
784000000
783000000
782000000
781000000
780000000
779000000
778000000
777000000
776000000
775000000
774000000
773000000
772000000
771000000
770000...

output:

799

result:

ok single line: '799'

Test #35:

score: 0
Accepted
time: 3ms
memory: 8500kb

input:

800
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

output:

0

result:

ok single line: '0'

Test #36:

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

input:

800
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000...

output:

1

result:

ok single line: '1'

Test #37:

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

input:

5
7
5
5
5
7

output:

2

result:

ok single line: '2'

Test #38:

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

input:

9
0
2
1
2
0
1
2
1
0

output:

4

result:

ok single line: '4'

Test #39:

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

input:

19
1
1
2
3
4
3
10
1
1
10
3
4
3
10
1
1
10
1
1

output:

9

result:

ok single line: '9'

Test #40:

score: 0
Accepted
time: 2ms
memory: 6816kb

input:

200
62
54
153
133
12
62
98
15
13
137
16
76
167
113
46
116
10
116
115
173
125
37
41
63
88
134
193
180
94
4
26
25
24
94
140
176
182
38
147
165
93
103
142
94
149
151
109
10
149
30
58
189
90
137
57
76
43
188
7
26
92
165
77
141
0
61
29
123
143
187
169
158
60
38
185
28
149
137
165
158
59
142
33
163
109
11...

output:

181

result:

ok single line: '181'

Test #41:

score: 0
Accepted
time: 2ms
memory: 6764kb

input:

200
2
0
0
1
1
2
1
0
2
2
2
2
2
0
1
1
1
0
2
2
2
2
2
1
0
0
2
2
1
2
2
0
2
2
0
0
1
0
2
1
0
2
1
0
2
2
2
0
1
2
2
0
0
0
2
1
0
1
1
2
0
2
0
2
2
2
0
1
0
2
0
0
2
0
2
1
0
1
0
0
1
0
1
0
2
2
1
0
1
1
1
1
1
0
0
1
1
0
0
1
1
0
2
2
0
1
1
2
0
1
1
2
0
0
1
2
0
2
2
1
2
1
2
0
1
0
1
2
2
0
2
2
0
0
2
0
2
2
0
1
0
1
1
2
1
0
2
0
...

output:

70

result:

ok single line: '70'

Test #42:

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

input:

50
1
0
1
0
1
1
2
2
1
1
1
2
0
2
0
0
0
1
0
0
0
1
0
1
2
2
0
1
1
1
1
2
2
1
0
0
0
0
1
1
1
1
1
0
0
2
0
2
2
1

output:

15

result:

ok single line: '15'

Test #43:

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

input:

50
11
12
5
41
12
1
0
45
18
38
1
4
40
13
2
37
8
2
22
18
29
4
39
25
16
6
44
1
28
1
20
49
12
31
20
47
2
8
12
39
22
47
45
14
49
47
6
24
29
16

output:

40

result:

ok single line: '40'

Test #44:

score: 0
Accepted
time: 14ms
memory: 8356kb

input:

500
31
8
74
145
2
54
140
108
61
184
41
76
161
165
58
124
1
169
81
130
112
193
85
199
128
168
87
37
68
168
10
135
60
87
153
37
19
0
43
140
142
124
130
34
71
109
132
168
67
176
113
183
7
20
105
16
123
65
38
105
133
51
127
169
107
111
53
46
72
116
135
188
0
18
27
182
162
26
116
180
84
43
132
178
118
66...

output:

445

result:

ok single line: '445'

Test #45:

score: 0
Accepted
time: 11ms
memory: 8780kb

input:

500
1
2
0
1
2
1
2
2
1
1
2
2
2
1
2
2
1
2
0
0
0
2
0
1
1
1
2
0
2
1
0
1
0
0
2
1
0
1
2
1
0
0
0
2
1
2
1
0
2
0
2
0
1
1
0
0
0
2
0
1
0
1
0
2
2
0
2
1
1
1
2
0
0
1
0
2
0
1
0
2
2
0
2
1
0
2
1
2
0
0
0
2
2
0
1
1
2
1
2
0
0
2
0
2
2
0
2
0
0
1
0
1
1
2
2
1
0
0
2
1
1
2
2
2
2
2
2
2
2
2
2
0
2
0
0
2
1
2
1
0
0
1
1
0
0
2
1
0
...

output:

176

result:

ok single line: '176'

Test #46:

score: 0
Accepted
time: 76ms
memory: 8684kb

input:

800
11
45
95
66
42
35
77
36
5
87
13
44
98
81
10
21
31
50
1
79
90
46
52
20
40
65
22
58
49
92
48
82
33
62
19
57
73
6
94
22
27
68
99
12
34
90
81
59
90
70
47
54
67
88
1
79
41
27
23
6
33
15
64
28
23
16
18
14
22
81
46
20
21
76
16
78
92
27
22
41
39
50
46
87
7
40
7
21
15
94
55
20
53
3
15
36
80
82
61
19
18
5...

output:

677

result:

ok single line: '677'

Test #47:

score: 0
Accepted
time: 73ms
memory: 8656kb

input:

800
110
161
16
62
169
25
69
126
144
50
19
17
39
170
12
148
110
50
36
164
31
156
76
53
137
86
33
178
145
178
9
99
4
158
87
53
154
56
161
135
93
82
84
7
84
22
148
93
144
46
160
25
134
59
149
32
64
185
46
12
68
144
107
139
185
109
190
115
158
195
116
56
89
131
14
167
133
129
52
114
76
195
51
6
192
182
...

output:

709

result:

ok single line: '709'

Test #48:

score: 0
Accepted
time: 55ms
memory: 8568kb

input:

800
1
1
2
0
1
0
2
2
0
0
0
1
1
0
2
1
2
2
0
0
2
2
1
2
2
0
1
0
1
1
0
0
2
2
1
2
0
1
1
2
1
1
2
2
0
0
0
0
0
2
2
0
0
2
2
1
2
0
0
1
0
2
2
1
1
1
0
0
2
2
0
1
1
0
0
2
2
1
1
2
0
1
1
1
0
2
0
0
0
0
0
1
0
0
0
1
0
0
0
2
1
0
1
0
0
2
0
2
2
0
0
2
0
2
0
0
1
0
2
1
0
1
1
2
2
1
1
0
0
0
1
0
1
0
2
2
1
0
0
2
2
0
0
1
1
2
2
0
...

output:

263

result:

ok single line: '263'

Test #49:

score: 0
Accepted
time: 81ms
memory: 8540kb

input:

800
166
44
266
290
19
286
138
73
45
278
182
287
294
126
251
236
89
198
284
79
1
215
97
52
230
202
53
21
61
240
171
64
73
59
264
188
197
229
110
177
151
204
41
264
70
230
161
240
150
2
49
295
89
151
214
171
106
147
59
212
162
287
120
245
120
129
15
98
91
122
219
6
246
265
26
293
215
215
44
245
61
219...

output:

728

result:

ok single line: '728'

Test #50:

score: 0
Accepted
time: 77ms
memory: 8664kb

input:

800
199
185
65
306
203
249
333
97
47
385
138
254
274
53
225
104
150
159
35
106
243
101
188
394
351
371
265
73
148
271
79
126
392
238
2
46
220
369
36
223
67
102
305
56
14
90
337
115
21
38
226
189
213
290
301
162
20
299
106
356
388
269
18
198
345
263
247
165
42
259
239
141
113
184
42
61
289
326
157
18...

output:

734

result:

ok single line: '734'

Test #51:

score: 0
Accepted
time: 78ms
memory: 8776kb

input:

800
579
734
695
126
649
151
487
555
192
172
509
337
463
650
397
532
660
482
186
557
179
393
569
377
605
783
776
260
320
99
176
93
369
664
509
500
397
307
266
504
244
461
308
112
208
728
446
720
590
228
467
249
654
441
651
389
694
561
315
405
277
297
377
371
474
244
427
60
574
348
425
156
637
87
759
...

output:

754

result:

ok single line: '754'