QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#307229#3926. Flow Finderucup-team1005#AC ✓85ms51912kbC++201.8kb2024-01-18 10:55:292024-01-18 10:55:29

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 9772kb

input:

10
1 2 3 2 1 6 7 7 6
0 4 2 2 0 5 0 2 0 2

output:

9
4
2
2
2
5
3
2
1
2

result:

ok 10 lines

Test #2:

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

input:

5
1 2 2 1
4 0 0 0 1

output:

impossible

result:

ok single line: 'impossible'

Test #3:

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

input:

4
1 1 1
3 2 1 0

output:

impossible

result:

ok single line: 'impossible'

Test #4:

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

input:

2
1
0 76397251

output:

76397251
76397251

result:

ok 2 lines

Test #5:

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

input:

12
1 1 1 3 2 6 7 5 5 10 4
24 10 11 3 11 10 0 10 1 10 0 0

output:

24
10
11
3
11
10
10
10
1
10
10
3

result:

ok 12 lines

Test #6:

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

input:

120
1 1 2 4 5 1 5 1 8 5 9 4 4 12 8 16 13 5 8 5 17 13 1 22 25 3 6 25 19 2 10 2 18 31 25 28 26 37 29 9 24 7 3 9 32 14 17 44 28 50 41 20 27 33 54 25 37 23 35 38 27 38 15 44 4 36 21 42 14 28 35 37 16 9 62 62 12 45 9 53 20 3 38 55 54 16 6 78 79 6 49 92 76 43 71 36 65 31 5 40 1 10 14 77 69 5 26 53 38 79 3...

output:

impossible

result:

ok single line: 'impossible'

Test #7:

score: 0
Accepted
time: 85ms
memory: 24812kb

input:

300000
1 2 1 4 4 2 1 2 1 7 9 5 13 13 1 8 17 18 12 9 6 4 9 7 1 21 26 9 26 9 7 11 20 19 24 6 22 25 33 16 12 16 31 18 6 36 20 1 19 37 46 20 49 33 13 27 28 39 19 28 29 11 15 40 34 6 11 6 60 36 67 69 61 44 19 26 9 53 26 57 36 24 46 56 76 42 82 72 26 42 13 8 91 30 36 75 79 31 16 43 23 38 59 4 6 46 90 11 3...

output:

75073184
38201514
3076246
13635309
3265673
8829334
11841779
6020306
22986577
4268482
6499768
10118274
3168896
1108907
913003
5978491
4822249
4711758
3983115
3977815
1606879
390068
272700
4027663
4309089
5008824
1351103
1629541
942547
2123311
4808611
485946
3796878
910384
1405440
3506160
1969397
1057...

result:

ok 300000 lines

Test #8:

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

input:

300000
1 2 3 1 4 2 7 3 5 5 8 10 9 12 14 11 16 14 14 20 17 20 20 20 23 22 22 24 28 29 29 28 29 29 30 32 33 34 35 37 38 38 42 44 45 42 43 48 45 48 48 47 50 52 51 52 54 53 56 57 60 61 58 63 65 66 64 63 66 67 68 70 73 71 71 74 75 78 75 75 78 77 83 81 83 81 86 86 86 88 90 87 91 89 95 92 96 94 94 96 99 99...

output:

501802170
51487
50183
5209
501750683
5209
1304
1304
44974
2449
501748234
1304
2449
44974
1304
63
501748234
63
6617
38294
8327
501748234
6684
16922
6361
6684
5323
501742911
16922
3106
4684
2156
501739805
5409
4673
3106
2156
501739805
5409
4673
2156
20594
501719211
15720
15720
6441
4874
501719211
1484...

result:

ok 300000 lines

Test #9:

score: 0
Accepted
time: 61ms
memory: 34152kb

input:

300000
1 2 2 1 1 3 7 7 7 8 7 10 12 11 14 16 17 14 16 20 21 20 23 20 24 24 23 26 28 28 30 28 30 32 31 32 37 35 37 39 38 42 43 44 41 44 44 48 48 48 49 52 49 50 55 56 54 54 59 58 59 59 62 63 62 63 67 65 69 66 68 69 69 72 75 76 77 76 77 79 81 81 81 81 84 82 84 87 89 89 87 91 90 90 95 95 96 97 95 100 100...

output:

492002430
491994142
491988852
5290
3531
4757
491988852
5509
2878
6572
5509
491973893
6572
491973893
5509
491972469
7459
7459
1424
491965010
374
374
491959350
15184
5286
6841
8343
491944166
6841
491930424
3968
491920904
9774
9520
6037
3968
491914867
491906313
6037
8554
6037
491906313
491906313
491906...

result:

ok 300000 lines

Test #10:

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

input:

300000
1 1 3 3 4 5 7 7 8 9 10 12 13 13 14 15 17 17 18 19 20 22 22 23 24 25 27 28 28 29 31 31 32 33 35 35 36 37 38 40 41 42 43 44 45 46 46 47 48 49 51 52 53 54 55 55 56 58 58 60 60 62 63 63 64 66 67 68 69 70 70 71 73 74 74 75 77 78 79 80 81 81 83 84 84 85 87 87 88 90 90 91 93 94 95 95 96 98 99 100 10...

output:

373027373
5353
373022020
9426
373012594
9426
373012594
373003513
9081
373003513
9081
373003513
373003513
9191
372994322
9191
372994322
372987137
7185
372987137
7185
372987137
372981404
5733
372981404
5733
372981404
372981404
372981297
107
372981297
4215
372977082
4215
372977082
372974197
2885
372974...

result:

ok 300000 lines

Test #11:

score: 0
Accepted
time: 57ms
memory: 24880kb

input:

300000
1 2 2 2 2 6 1 2 3 4 9 4 7 11 1 15 16 15 13 16 19 7 13 3 16 8 25 1 23 9 17 27 31 25 8 17 7 5 25 40 25 7 43 4 22 16 45 6 32 42 34 14 38 52 10 39 5 35 3 32 45 13 10 59 57 37 46 55 18 21 13 69 41 46 64 65 26 40 20 46 68 37 66 10 65 70 29 45 32 2 38 44 29 35 5 55 33 49 39 91 54 23 85 51 15 22 85 4...

output:

impossible

result:

ok single line: 'impossible'

Test #12:

score: 0
Accepted
time: 57ms
memory: 21196kb

input:

300000
1 2 2 2 2 6 1 6 9 8 10 2 6 9 15 2 13 6 15 14 6 6 8 2 4 5 17 28 19 3 25 25 7 19 14 15 27 6 18 14 26 18 22 3 13 46 1 27 4 25 32 9 2 16 28 48 55 8 39 1 8 49 38 26 26 43 2 11 18 70 3 65 11 74 64 69 26 54 9 51 25 82 12 75 19 23 78 6 7 35 72 88 78 20 35 95 74 5 16 91 52 31 21 79 65 6 95 47 109 87 6...

output:

impossible

result:

ok single line: 'impossible'

Test #13:

score: 0
Accepted
time: 58ms
memory: 24900kb

input:

300000
1 2 2 1 2 4 7 8 5 3 1 9 8 6 2 8 12 2 14 5 20 12 13 14 10 22 9 15 6 22 10 24 9 30 16 29 25 3 38 1 16 9 13 20 35 24 16 21 43 36 29 28 31 5 42 38 21 55 33 11 54 15 63 53 31 5 5 64 39 10 69 11 20 50 73 48 77 20 15 13 57 22 25 45 56 54 58 32 88 36 19 80 67 23 16 35 59 39 22 85 84 23 100 23 62 99 4...

output:

impossible

result:

ok single line: 'impossible'

Test #14:

score: 0
Accepted
time: 63ms
memory: 24772kb

input:

300000
1 2 2 2 2 5 4 3 2 8 5 3 2 9 13 2 13 15 6 20 1 17 3 2 2 7 8 20 1 25 15 21 29 13 34 15 19 32 1 6 30 42 18 27 36 6 46 17 21 49 15 33 19 2 5 37 50 7 26 7 55 19 25 9 3 1 28 27 7 61 49 51 54 10 73 26 35 44 12 40 43 2 53 16 18 32 13 2 8 60 63 23 88 72 25 58 66 25 94 99 17 54 83 50 15 51 54 28 1 35 1...

output:

impossible

result:

ok single line: 'impossible'

Test #15:

score: 0
Accepted
time: 66ms
memory: 24908kb

input:

300000
1 2 3 3 2 4 1 6 8 5 11 8 12 14 10 8 1 5 15 12 6 11 7 2 19 7 3 17 22 27 11 26 6 2 4 33 15 6 28 29 8 28 9 35 21 40 36 11 45 4 36 11 33 53 6 26 39 27 43 39 31 31 39 50 4 11 25 34 46 47 50 40 15 33 31 43 47 48 66 74 65 23 4 49 56 5 67 4 29 87 55 6 50 27 78 14 97 71 29 23 10 90 36 5 56 36 64 45 78...

output:

749334000
679548023
462296858
221064059
178445604
142355292
132570713
58591766
25366203
26587154
123149859
32028387
4054228
12603474
6658016
20174609
18845895
1143878
26277628
1774185
13419889
18905927
10495407
10800091
12668232
22439930
104202095
59486507
14449571
8839746
43489825
3678086
13664970
...

result:

ok 300000 lines

Test #16:

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

input:

300000
1 2 3 2 2 6 2 4 3 3 2 9 4 12 5 1 14 5 1 9 5 3 9 15 24 14 5 26 29 9 12 15 32 28 24 28 21 8 23 39 41 17 29 36 40 9 29 44 47 29 35 12 19 13 12 34 23 17 24 30 17 39 18 51 17 63 31 31 25 47 17 10 56 60 50 1 55 6 29 19 64 57 82 33 21 53 33 45 26 81 48 67 92 85 18 91 78 31 93 64 28 80 6 75 90 76 5 4...

output:

149595
137651
77118
61257
14708
4484
345
11994
49062
7437
701
27978
5435
12155
12857
829
5040
6683
7363
893
3073
1392
7106
29495
3276
16548
3058
4026
14113
1730
3682
7490
6100
5795
1718
3928
967
1680
11160
3922
2797
620
1612
3191
2447
2559
3277
3240
2075
2165
715
1046
1711
1466
4572
3646
5167
2672
1...

result:

ok 300000 lines

Test #17:

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

input:

300000
1 1 2 3 3 6 1 8 5 8 11 7 7 13 15 4 9 8 11 12 9 12 21 21 17 5 6 18 22 22 9 11 1 5 8 22 2 6 18 14 25 26 38 29 39 7 42 44 8 38 38 41 41 24 12 56 7 48 56 32 33 44 13 35 58 28 63 37 65 33 14 16 12 36 36 16 4 21 53 15 68 76 12 55 62 22 69 50 59 40 63 59 56 54 77 13 33 61 51 31 58 79 63 9 73 19 63 9...

output:

75030890988843
11064972515416
31384588944075
2380385903968
5540470718180
25296762126195
21441102551744
28885824697672
9991685384165
65211051380
16030296038017
12314097169231
9957784768478
6410506374546
8264563045992
7060728424893
1224105140683
3554391855104
365353732770
589496477246
6610077557765
29...

result:

ok 300000 lines

Test #18:

score: 0
Accepted
time: 58ms
memory: 51912kb

input:

300000
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 1...

output:

142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
142486564
...

result:

ok 300000 lines

Test #19:

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

input:

10001
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

impossible

result:

ok single line: 'impossible'

Test #20:

score: 0
Accepted
time: 30ms
memory: 13972kb

input:

300000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

impossible

result:

ok single line: 'impossible'

Test #21:

score: 0
Accepted
time: 52ms
memory: 32068kb

input:

300000
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 1...

output:

750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
750903123
...

result:

ok 300000 lines

Test #22:

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

input:

300000
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 1...

output:

150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000
150000...

result:

ok 300000 lines

Test #23:

score: 0
Accepted
time: 38ms
memory: 13860kb

input:

300000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

149923521447319
972423195
776100482
736859791
844690425
823033043
944853777
971324294
162355437
278987595
723712502
682605453
911972024
971678046
109002522
936442861
351571715
615190353
972198084
181868341
28969601
441869526
436734028
80539400
110861487
134300597
342673052
509389020
623484865
482540...

result:

ok 300000 lines

Test #24:

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

input:

300000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

299999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 300000 lines

Test #25:

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

input:

300000
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 1...

output:

impossible

result:

ok single line: 'impossible'

Test #26:

score: 0
Accepted
time: 31ms
memory: 33088kb

input:

300000
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 1...

output:

impossible

result:

ok single line: 'impossible'

Test #27:

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

input:

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 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
0 49 0 5...

output:

impossible

result:

ok single line: 'impossible'

Test #28:

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

input:

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 90 90 90 90 90 90 90 90 90
0 42407 ...

output:

impossible

result:

ok single line: 'impossible'

Test #29:

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

input:

9999
1 1 2 1 2 4 1 3 7 4 7 12 4 13 12 1 8 5 5 7 20 16 13 12 8 19 1 1 24 10 28 8 33 3 1 30 36 21 21 28 28 13 4 17 13 40 25 28 39 34 10 4 7 5 9 35 36 46 50 3 4 27 14 48 12 42 14 53 6 54 59 10 6 46 13 31 11 18 36 45 78 56 45 67 61 78 50 5 6 20 73 2 67 15 80 89 61 5 75 24 79 5 89 3 104 55 7 38 55 21 9 3...

output:

19168944
9410821
2460224
8557689
2168127
773842
6912083
1482200
961865
814832
406872
3678222
2533975
421091
313988
312609
375863
816853
474981
165570
994153
17369
233
941744
396260
343983
421477
992062
917705
753780
376962
33208
201235
151980
785359
1257421
194206
987882
259656
367675
461080
384233
...

result:

ok 9999 lines

Test #30:

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

input:

9999
1 2 2 2 1 1 3 6 5 6 7 3 4 4 8 3 3 14 14 2 15 12 1 21 16 9 5 20 11 20 21 15 10 7 26 20 3 34 6 11 30 10 17 35 4 12 42 1 29 50 10 23 37 37 27 5 20 29 56 53 30 23 1 47 21 34 23 62 46 67 8 67 32 22 27 63 72 12 43 44 8 51 44 82 15 39 33 72 89 11 39 59 60 37 66 16 75 3 37 28 99 62 71 70 88 16 1 76 8 4...

output:

12282
10562
8632
1027
589
734
612
8036
307
424
383
507
186
718
244
7504
239
10
76
638
300
57
239
35
19
63
300
38
246
284
14
36
56
217
73
44
361
84
102
1
2
154
122
54
1
40
78
52
134
143
106
74
40
50
185
175
109
16
63
131
6
81
114
50
1
161
38
55
3
27
6
294
18
10
42
52
60
71
110
102
34
133
94
2
119
30
...

result:

ok 9999 lines

Test #31:

score: 0
Accepted
time: 85ms
memory: 24812kb

input:

300000
1 1 3 2 2 2 6 8 7 4 4 3 7 3 14 5 7 7 1 14 8 3 4 14 11 23 27 5 6 29 30 18 15 29 9 13 1 19 17 6 34 35 18 8 37 27 11 13 24 5 3 28 49 54 52 32 24 11 25 52 17 54 62 50 65 23 30 23 40 25 69 54 4 29 26 8 42 46 52 14 64 20 64 67 27 70 58 73 55 21 86 54 32 60 38 60 30 31 5 2 56 53 88 71 33 57 18 107 1...

output:

522167697
229860124
235159929
71348640
62446750
66749074
91772825
35091034
17529141
9990667
16007618
11556
34305358
36781267
8664377
11247776
33077403
24782945
16933178
31675134
1660529
1524268
89966007
50927868
20681161
11143132
35780432
14654164
15664432
17381845
2660585
13082814
2026364
5599820
4...

result:

ok 300000 lines

Test #32:

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

input:

300000
1 2 3 3 1 5 3 7 7 1 1 2 8 11 4 12 3 16 11 20 18 14 7 15 6 8 14 26 14 22 26 13 28 20 18 33 15 27 31 34 10 20 20 38 42 31 26 40 7 47 25 11 20 14 50 28 12 44 35 21 38 53 55 42 45 35 57 61 29 41 69 67 64 71 72 70 41 71 47 31 80 34 59 61 71 45 65 48 58 41 45 89 46 93 87 66 55 49 90 84 55 55 86 103...

output:

431163633
430961598
430958357
7625
19689
32808
19689
430882346
4110
7413
152832
16395
3241
430876515
76977
7625
3833
48697
7625
71914
9133
46104
1581
4811
7903
32808
5831
150116
8306
1
46104
7385
3241
150115
21542
2593
3241
69074
5831
33382
30997
7413
1
41237
65033
4225
9555
17117
33382
3355
6265
79...

result:

ok 300000 lines

Test #33:

score: 0
Accepted
time: 67ms
memory: 30440kb

input:

300000
1 1 3 2 3 1 4 7 3 2 9 3 12 8 6 8 10 18 18 17 17 21 15 21 16 20 27 23 26 30 23 27 32 26 35 34 32 31 34 35 36 41 35 37 39 42 39 39 46 49 46 45 52 47 53 52 56 56 55 59 57 54 54 56 63 64 62 66 64 70 66 65 66 67 74 71 74 72 73 78 77 79 83 79 84 83 84 83 87 86 86 91 86 87 90 95 93 89 93 92 97 101 9...

output:

419314081
7596
419306484
46304
4774
419260176
1
46304
1
3
2822
1
1
1
9282
419260176
37022
3
1
2
32967
4055
29208
9282
3759
419260176
2
1
558
419250922
419250922
28650
1
25258
9254
3657
18170
3392
419250922
7088
4326
3657
4326
1271
18170
419238193
3657
9701
3028
2457
3028
419235736
18170
419228462
36...

result:

ok 300000 lines

Test #34:

score: 0
Accepted
time: 67ms
memory: 34224kb

input:

300000
1 2 1 4 2 2 4 4 9 7 8 9 9 10 12 13 17 17 19 19 18 22 19 20 21 25 25 25 26 28 30 30 33 31 32 33 36 38 39 36 37 39 41 41 42 43 46 44 45 50 50 49 50 53 53 53 55 55 58 56 59 60 61 62 65 65 66 66 66 66 69 69 73 74 75 74 73 75 76 76 81 80 79 83 83 84 84 84 88 87 89 91 92 90 95 92 95 94 95 97 98 100...

output:

399980694
20472
4581
399960222
4939
6894
8997
9499
399945784
5330
8997
9499
399934410
6044
5330
9499
399934410
4907
399929503
15706
399903909
4907
4907
9888
15706
399903909
3383
5304
7019
399903909
5304
399898858
5051
2553
5304
399898858
2498
9575
9575
8192
399889283
2498
1383
399887804
1479
2498
13...

result:

ok 300000 lines

Test #35:

score: 0
Accepted
time: 63ms
memory: 42688kb

input:

300000
1 1 2 4 4 6 6 7 8 10 11 11 13 14 14 15 16 18 18 20 20 22 22 24 24 25 26 27 29 29 31 31 32 34 34 35 37 38 39 39 41 41 42 44 44 46 47 47 48 50 51 52 52 54 54 55 57 57 58 59 60 62 62 64 64 66 66 67 68 70 70 72 73 74 75 75 77 77 78 80 81 82 82 83 85 86 86 87 88 90 90 91 92 93 95 96 96 98 99 99 10...

output:

339011205
339006838
4367
339006838
7131
338999707
9605
338990102
9605
338990102
338990102
6752
338983350
338983350
9955
338973395
9955
338973395
661
338972734
1217
338971517
105
338971412
338967795
3617
338967795
3617
338967795
1
338967794
338967793
1
338967793
338963231
4562
338963231
338963231
338...

result:

ok 300000 lines

Test #36:

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

input:

300000
1 1 2 4 5 5 2 6 9 8 8 5 11 11 2 10 14 10 17 16 2 20 22 14 9 11 18 25 22 8 4 4 21 19 14 5 24 8 21 16 33 18 21 1 23 34 43 20 36 26 25 12 44 8 3 24 56 41 48 44 36 55 8 9 20 12 16 41 1 8 53 36 45 26 25 50 59 77 61 46 76 69 59 40 63 9 2 62 49 49 47 15 86 32 2 70 82 57 93 41 90 21 64 94 79 62 5 89 ...

output:

180486
164289
3293
48874
43570
38376
968
72085
35072
19364
51337
2115
1803
44732
4716
33479
18376
11611
690
15584
21892
5296
2125
3604
6170
9535
370
490
58
924
744
2366
1710
2056
429
26806
1661
203
7579
7132
9591
91
11049
8364
9556
725
1970
9495
4566
10421
6698
2293
653
1751
6466
1863
1363
902
5021
...

result:

ok 300000 lines

Test #37:

score: 0
Accepted
time: 82ms
memory: 24888kb

input:

300000
1 1 1 1 4 3 1 7 5 6 2 10 9 14 3 4 9 12 1 5 17 3 2 12 9 24 18 23 27 2 26 25 11 20 19 25 21 14 14 29 35 12 39 9 37 46 26 35 28 16 16 44 53 8 38 43 48 5 52 29 18 27 8 37 26 23 52 44 58 12 67 61 54 60 47 17 57 36 18 30 21 38 40 9 39 67 14 75 68 39 53 30 53 40 69 93 46 96 79 59 9 10 94 7 44 53 42 ...

output:

185823
46253
82919
8201
26582
2989
58123
13542
56424
4726
2093
34162
230
34627
447
6346
4719
7797
5277
2702
19080
1632
15383
4903
22233
8579
3740
1456
3617
2233
3984
124
2134
1027
2191
5277
16657
15731
22229
8420
769
1912
4932
20288
785
5393
3387
7250
89
269
301
4978
7156
787
385
1287
2618
5563
2614...

result:

ok 300000 lines

Test #38:

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

input:

300000
1 1 3 3 2 3 4 5 1 9 5 11 6 13 12 4 12 1 17 1 4 16 12 24 1 11 22 16 2 1 8 21 6 11 22 11 37 5 31 24 6 19 11 37 5 44 9 35 47 29 32 21 26 40 25 3 17 50 39 50 30 33 36 6 15 44 61 13 10 49 52 26 57 50 1 34 75 29 32 75 23 3 11 13 15 23 4 17 63 79 79 2 86 60 65 22 97 69 38 70 57 95 51 104 7 90 50 106...

output:

190467
21772
131794
44942
73370
17708
6765
5153
42417
16511
41511
22305
5333
6368
2104
14408
1157
787
1928
553
5993
35603
1805
5237
696
7261
3216
3738
11246
2836
2383
4521
5062
1237
2113
25668
7673
5696
7095
1015
823
283
219
20263
1262
1482
12750
245
850
12497
2884
1416
244
3077
769
9
5023
262
1160
...

result:

ok 300000 lines

Test #39:

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

input:

300000
1 1 1 3 1 1 5 3 4 5 11 7 6 9 5 3 14 16 13 12 13 8 13 6 4 17 16 23 25 7 17 19 12 32 21 36 11 1 39 25 32 9 14 27 24 14 32 47 49 17 40 3 16 41 33 30 42 33 19 29 47 6 55 31 39 27 22 23 9 31 48 56 70 3 49 45 63 22 69 73 33 11 13 84 59 27 29 46 19 18 24 70 82 11 61 36 36 38 1 70 39 89 72 8 39 5 64 ...

output:

751708310
3007575
468917594
24803409
300474175
131506760
92639005
80115234
61479250
3789776
84621120
54687817
72400335
55874017
7069241
129315147
93130020
7239798
105519400
6954434
47086878
20255950
66298546
38283068
40045579
16027223
31431116
8218045
47882797
10362341
10178239
49863743
95274466
166...

result:

ok 300000 lines

Test #40:

score: 0
Accepted
time: 60ms
memory: 24744kb

input:

300000
1 1 3 3 4 5 7 2 8 10 5 7 12 7 8 5 2 3 14 3 18 10 12 21 23 14 27 19 19 12 21 3 14 33 27 5 1 1 33 24 5 38 15 2 21 23 34 11 2 47 1 14 48 47 20 45 15 33 42 59 20 40 3 37 35 27 62 19 28 35 7 57 58 14 72 1 35 31 12 57 17 44 45 4 13 20 9 74 21 81 65 85 32 68 37 61 4 74 24 70 38 18 28 15 89 22 55 75 ...

output:

impossible

result:

ok single line: 'impossible'

Test #41:

score: 0
Accepted
time: 50ms
memory: 24880kb

input:

300000
1 2 3 1 1 3 6 8 6 1 10 11 3 10 6 11 9 11 10 16 19 13 8 20 3 17 16 5 14 17 8 1 25 24 35 33 2 10 31 7 17 8 9 30 6 8 26 19 44 12 23 30 27 32 19 41 17 12 28 17 45 45 11 48 11 31 67 32 39 4 19 55 31 47 9 4 68 73 45 75 5 29 49 19 57 85 9 21 77 75 6 70 57 1 19 49 18 67 97 76 87 96 94 34 26 5 44 89 3...

output:

impossible

result:

ok single line: 'impossible'

Test #42:

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

input:

10
1 2 3 4 5 5 4 5 5
0 5838 0 5839 0 0 0 0 0 5835

output:

impossible

result:

ok single line: 'impossible'

Test #43:

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

input:

10
1 2 3 4 4 4 6 5 5
0 17941 0 17942 10250 7222 470 7222 4541 5709

output:

impossible

result:

ok single line: 'impossible'

Test #44:

score: 0
Accepted
time: 49ms
memory: 24884kb

input:

300000
1 2 3 4 5 4 5 7 8 9 8 12 8 10 15 16 13 4 11 4 18 8 8 14 9 12 24 26 23 22 5 7 29 22 6 31 22 17 8 27 34 12 39 5 11 10 13 48 15 7 21 24 18 43 5 42 40 15 31 60 54 58 7 23 29 13 17 15 56 6 67 54 33 6 14 21 13 62 55 58 72 39 73 7 5 63 45 26 21 12 9 91 17 88 94 20 56 87 94 99 14 81 71 57 80 16 34 32...

output:

impossible

result:

ok single line: 'impossible'

Test #45:

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

input:

10
1 1 3 3 2 2 2 2 9
0 0 0 9864 8280 3812 0 0 0 3583

output:

impossible

result:

ok single line: 'impossible'

Test #46:

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

input:

100
1 2 3 2 4 3 6 2 8 10 8 10 1 9 7 12 14 13 6 2 4 4 13 5 4 6 17 27 16 5 25 25 33 18 12 25 5 4 38 4 12 4 11 19 18 5 34 40 7 38 42 42 44 4 7 55 40 30 51 42 58 47 22 43 57 22 17 11 41 7 35 48 24 10 71 15 39 64 47 56 6 61 54 78 11 46 17 83 12 86 20 74 40 14 89 69 55 57 76
0 0 147545 126563 38426 0 2098...

output:

211203
196154
147545
126563
38426
91308
20982
75048
9737
35521
14891
39527
11023
15049
9737
3825
14450
6887
3548
5571
446
5116
1573
7475
16670
1004
7510
8216
7510
3825
995
3685
6697
6697
5364
6376
6288
11236
3377
10398
6520
17273
8808
6630
3548
1523
9525
6697
3077
5660
838
3637
4914
6630
8857
9432
3...

result:

ok 100 lines

Test #47:

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

input:

100
1 1 1 4 2 3 1 4 2 10 1 2 3 13 9 10 13 13 11 12 3 11 10 20 6 4 17 3 19 4 9 21 7 19 3 23 25 7 31 31 13 13 9 17 16 4 3 44 44 28 46 3 48 46 45 48 55 42 52 22 24 54 31 59 20 30 62 59 45 6 36 21 2 29 2 75 72 70 37 46 73 26 52 15 47 44 15 29 78 8 56 7 87 80 61 16 19 23 83
0 0 53704 85418 3797 5195 4427...

output:

250635
90001
53704
85418
3797
5195
4427
8047
48040
45490
27506
13465
30753
4098
2
18614
15826
7416
14282
10161
13465
6488
17345
2158
7991
1063
6758
4565
13878
2169
20250
4452
8264
1197
2287
4951
8952
7991
2158
9176
3838
8485
568
24974
11261
13208
6573
10422
8244
8740
4565
7844
9440
4490
1380
4656
59...

result:

ok 100 lines

Test #48:

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

input:

100
1 2 2 3 1 3 3 1 2 8 1 2 5 13 2 10 2 3 5 9 5 7 23 14 3 20 14 5 23 2 30 3 12 21 17 23 21 7 27 6 2 22 21 25 45 34 43 35 41 47 40 52 45 42 17 38 43 4 32 59 24 59 14 45 20 3 32 64 55 38 27 54 50 49 19 75 59 71 12 72 50 8 66 79 4 80 70 85 81 67 37 41 39 22 24 2 80 36 7
0 0 87233 0 0 15006 22025 6666 2...

output:

impossible

result:

ok single line: 'impossible'

Test #49:

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

input:

100
1 2 1 2 5 2 5 1 1 2 6 11 1 14 1 5 10 17 11 3 13 16 12 5 16 15 27 3 15 24 23 8 28 15 22 33 29 18 10 7 39 23 5 39 22 30 26 12 25 20 23 50 50 14 54 8 38 16 40 46 46 46 44 41 9 37 15 48 24 47 68 22 70 25 9 51 13 44 23 74 1 24 39 52 74 85 3 67 84 5 26 31 47 11 10 51 57 84 23
0 0 0 0 0 0 0 0 0 6 0 0 6...

output:

impossible

result:

ok single line: 'impossible'

Test #50:

score: 0
Accepted
time: 56ms
memory: 24832kb

input:

300000
1 1 2 4 5 3 3 7 7 10 1 7 11 1 2 1 9 16 18 1 11 19 14 8 8 17 17 12 15 8 2 24 23 22 13 16 3 9 22 7 24 38 25 33 35 17 7 42 15 45 22 14 31 48 8 50 27 39 23 44 56 19 57 31 34 46 6 62 40 51 34 67 29 15 27 49 63 33 78 72 20 57 2 22 71 81 11 10 35 66 80 70 61 56 47 5 78 34 83 78 67 87 61 91 82 103 41...

output:

impossible

result:

ok single line: 'impossible'

Test #51:

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

input:

300000
1 1 3 3 5 2 6 7 3 3 11 2 8 11 4 7 17 18 17 5 16 7 1 3 14 3 5 16 22 6 31 9 4 19 22 22 7 16 18 17 1 37 19 41 9 23 42 28 12 13 26 51 53 51 39 18 2 24 7 19 37 19 38 64 15 15 29 19 43 61 69 41 56 15 2 48 55 54 41 1 75 82 52 61 55 78 34 20 48 25 60 73 92 29 82 74 22 29 20 21 36 84 75 104 94 89 56 7...

output:

748230978
360046277
326724554
128735992
63995130
52506517
250327525
20600454
17581526
4561827
84793981
13183959
87912339
17285225
62309224
111026713
165540143
114386856
63781530
18508355
3449993
46298794
24494570
24072752
33317786
17141781
7346547
3126703
21489227
246190
19598129
14708037
8758095
87...

result:

ok 300000 lines