QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#622036#4339. 青蛙题 / rmscnerotcar07100 ✓2755ms159536kbC++201.5kb2024-10-08 19:37:072024-10-08 19:37:08

Judging History

你现在查看的是最新测评结果

  • [2024-10-08 19:37:08]
  • 评测
  • 测评结果:100
  • 用时:2755ms
  • 内存:159536kb
  • [2024-10-08 19:37:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=2e6+5;
int n,q;
#define ls p<<1
#define rs p<<1|1
struct seg1{
    int t[maxn<<2],g[maxn<<2];
    inline void pushup(int p){t[p]=min(t[ls],t[rs]);}
    inline void pushdown(int p,int l,int mid){
        if(g[p]){
            g[ls]=g[rs]=g[p];
            t[ls]=g[p]-l+1;
            t[rs]=g[p]-mid+1;
            g[p]=0;
        }
    }
    void modify(int p,int l,int r,int ql,int qr,int k){
        if(ql<=l&&r<=qr) return t[p]=k-r+1,g[p]=k,void();
        int mid=l+r>>1;
        pushdown(p,mid,r);
        if(ql<=mid) modify(ls,l,mid,ql,qr,k);
        if(qr>mid) modify(rs,mid+1,r,ql,qr,k);
        pushup(p);
    }
    int query(int p,int l,int r,int ql,int qr){
        // cout<<p<<' '<<l<<' '<<r<<' '<<g[p]<<' '<<t[p]<<'\n';
        if(ql<=l&&r<=qr) return t[p];
        int mid=l+r>>1,res=n+1;pushdown(p,mid,r);
        if(ql<=mid) res=query(ls,l,mid,ql,qr);
        if(qr>mid) res=min(res,query(rs,mid+1,r,ql,qr));
        return res;
    }
}A;
int lst[maxn],a[maxn],fa[maxn];
vector<pair<int,int>> Q[maxn];
int ans[maxn];
inline int getfa(int x){return fa[x]==x?x:fa[x]=getfa(fa[x]);}
int main(){
    cin>>n;for(int i=1;i<=n;i++) cin>>a[i],fa[i]=i;cin>>q;
    for(int i=1,x,y;i<=q;i++) cin>>x>>y,Q[y].emplace_back(x,i);
    for(int i=1;i<=n;i++){
        int x=lst[a[i]];A.modify(1,1,n,x+1,i,i);fa[getfa(x)]=getfa(x+1);
        lst[a[i]]=i;
        for(auto [x,id]:Q[i]) ans[id]=A.query(1,1,n,x,getfa(x));
    }
    for(int i=1;i<=q;i++) cout<<ans[i]<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 30
Accepted

Test #1:

score: 30
Accepted
time: 44ms
memory: 16760kb

input:

49877
5 19104 10024 26645 44019 3799 47144 18957 16261 7730 49099 47900 6246 42506 7445 29494 29292 23364 40488 16750 6800 21668 27296 36297 18566 37148 15851 40842 5872 11177 46903 1732 38477 12305 27376 35840 33232 36691 34829 20037 36492 33175 40983 7253 13581 2 4603 3443 22203 49583 38890 14550 ...

output:

308
2669
29667
1994
4344
2206
9866
9432
6497
15313
4691
35920
2504
13085
18158
43914
7180
24316
10061
27155
1061
20339
15978
32174
9761
41891
33530
8350
7624
7071
28284
17943
37105
24743
12989
2822
11094
26076
15015
6211
5570
38782
3664
8493
8295
3086
2482
16262
17710
4164
1998
21064
40699
9000
7959...

result:

ok 50000 numbers

Test #2:

score: 30
Accepted
time: 46ms
memory: 12804kb

input:

48903
2 10129 23488 26693 40529 22667 9151 39609 45019 29968 30220 6532 5 38845 4813 41139 44902 13789 110 38170 4 30856 21452 44227 14073 19630 45010 15793 28903 1141 6529 10 34172 47755 32164 3 6400 36982 14285 3 6 36064 33581 24833 27855 8249 217 23024 13661 35819 5401 35021 1737 782 38233 3 1809...

output:

119
17462
2393
17882
1710
30926
33261
25350
4927
27634
24627
46111
5565
690
12661
12332
8325
37701
30040
22603
22694
6860
5362
1155
25016
4391
24641
2894
16623
26349
11317
8016
17151
9716
26302
2495
8734
22108
28456
39652
11793
657
20071
15425
16084
29276
29784
13659
8960
32884
9994
31601
3223
18218...

result:

ok 50000 numbers

Test #3:

score: 30
Accepted
time: 39ms
memory: 7408kb

input:

45088
17 11 14 13 11 4 16 6 22 19 9 11 18 15 4 23111 10 17 20 9 8 22 6 15 3 9 18 15351 6 11 32695 12 14 19 17 8 4 16 21 15 18 35832 12 21 8 21 5773 19 20 17 11 12 19 9 12 17 14 12 9 14 6 21 20 13 16 5 11 2 11 5 7 6 16 17 19 9 17 22265 3 26 10 4 15 11 16 27889 11 5 11 20 18 22475 25338 14 6 20 18 15 ...

output:

25635
3382
32069
27600
30820
4321
4032
29078
11988
28664
11054
4415
3058
15380
4886
20693
7695
2546
2003
3345
3842
17428
26611
70
18210
18765
21563
2260
32679
334
8242
14504
5226
25197
23178
10236
21552
1062
19157
17336
18919
21209
25065
8878
19684
20150
18837
27915
8122
5473
12001
17939
39481
5904
...

result:

ok 50000 numbers

Test #4:

score: 30
Accepted
time: 40ms
memory: 7472kb

input:

46783
10 15637 739 1476 43357 44091 11 41930 14124 37374 31215 16676 29721 17138 40618 25729 1820 24622 17526 24068 34205 34358 96 39222 28566 17132 289 4132 43176 45480 4828 30401 35995 37126 28142 40068 2636 8097 31368 25256 30859 46643 17193 15699 38365 36812 6 11646 9 26408 8374 9 44901 4920 437...

output:

10015
3934
23365
9623
20066
26440
42984
25095
28127
8045
9817
36437
15017
20590
19527
21534
11658
17902
23355
15074
4185
5445
40327
11475
1922
21702
73
27053
19327
20679
24225
44754
5477
21823
25278
904
20451
34982
23825
7453
16598
363
14527
39368
33018
7728
18275
3851
18988
3343
3794
272
34729
1614...

result:

ok 50000 numbers

Test #5:

score: 30
Accepted
time: 39ms
memory: 7488kb

input:

46437
7 7 3 41736 22 8 18 13 19 29 32 8 25695 12 16 11 48 11 23 13503 11 23 33 41473 33 16 17421 43 11 26 31 30326 20 6 18 7 15 37 13 13 9 42 21 16 7647 16 16416 28 39 13 27 44 45199 21 19 7442 10 23 31 16 28 16 23 33296 14 18 14 13 17 26450 17 18 14 35 9 24 49 12 25985 16 27 22 13 10 38 21 21 11 25...

output:

7085
10225
4666
1218
2547
9393
10373
1156
36990
22822
22376
7936
24754
23083
1065
11548
7481
8547
7245
13232
6157
25169
4579
17978
17455
23171
24219
28104
15598
40640
41672
39509
19772
3532
22919
10169
15463
11274
14701
1495
5798
36278
26335
4602
5576
10906
1826
13733
20468
4674
23095
20772
37147
54...

result:

ok 50000 numbers

Test #6:

score: 30
Accepted
time: 44ms
memory: 7560kb

input:

49424
19 9 7 23 8 14 18 11 18 4 3 3 4 14 4 10 18376 47215 12935 2382 9 15315 18360 9 20 45930 5 22 15 4 3394 8 19 13 11 11 7566 9 20 9 44785 5 16284 9 14 6 18174 16103 5 11 15 5 13 25 15 7 10 10 16 5 27912 12 5 5 4 6127 14 9 11 10 22 8 28418 6 34205 15 8 6 6 4 12 4 6775 826 16 28 10 8 6 11 5 44770 6...

output:

12767
30827
7064
32033
4351
16409
2870
1702
2286
40557
30823
1570
6953
2958
22284
3482
15205
2960
20299
3168
8156
5047
10649
11657
4213
3560
2888
4935
130
33956
3912
692
34083
202
16165
15790
5900
11603
11575
12925
26386
241
21503
8170
46777
29905
40601
30543
40366
1113
40253
32671
16441
22011
8764
...

result:

ok 50000 numbers

Test #7:

score: 30
Accepted
time: 42ms
memory: 7552kb

input:

48369
9136 6961 41663 905 47324 36889 26583 21315 5 6395 3832 27102 7498 37493 48305 29074 19180 23017 16024 26876 47779 38997 40082 15342 33531 38539 3324 45379 18483 20261 43141 18962 3259 43972 17913 13596 11 42171 40216 2461 4986 45551 39979 724 11393 10 30699 41042 29716 5 28168 34657 26203 493...

output:

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

result:

ok 50000 numbers

Test #8:

score: 30
Accepted
time: 38ms
memory: 7576kb

input:

47340
8 31610 38874 23948 41791 7 6263 8 39474 9205 13682 24972 9026 7143 44381 9537 39368 1066 3 11742 16656 18704 10762 10495 23403 8906 28166 16438 8540 26718 26044 29104 20907 4892 5920 11957 27279 4462 17429 11 8 40492 6218 4782 5 14735 27555 29337 20656 1628 3 8667 24405 43225 23184 33808 7 20...

output:

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

result:

ok 50000 numbers

Test #9:

score: 30
Accepted
time: 39ms
memory: 7592kb

input:

47893
9 36937 11 19 15 11 8 15 5 18 3 11 7 15 12 4 8 7 15 19 13 13 16 5 3 8 19 17 10 20 10 16 5 22 18 18 20 7 5 28421 17 9 3 6 2 16 10 21 6 7 7 17 8 6 13 7 14 21 15 5 18 12 3 19 11541 9 15 17 3 3 16 18198 8 6 27 19 24185 22 9 16 41842 10 7 16 5 13 17 15 13 25444 17 16 13 17 3 4 7 20 13 11 2 3607 7 1...

output:

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

result:

ok 50000 numbers

Test #10:

score: 30
Accepted
time: 42ms
memory: 7500kb

input:

47428
22726 21485 42376 26714 44838 34476 269 4697 8682 17715 15920 34330 15816 29214 14 39123 39000 251 24930 18300 25852 5 42334 9193 10133 9896 21468 42313 29707 16723 26389 40873 22548 30998 44775 24075 27934 6151 21350 5273 35747 44933 32373 32293 41873 13253 12 8714 16127 13340 28998 10272 402...

output:

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

result:

ok 50000 numbers

Test #11:

score: 30
Accepted
time: 36ms
memory: 7528kb

input:

46296
26 22 15 13623 29 14 691 21 18 40 41 20 16 16 35 38 20060 19 28157 24 22 9 12 26 12 16 15 45 4 7826 19 2701 14 17 33 41337 79 20 10 19 26 20 14 26189 26 22 9 9 21 44 12 17 14 11 10 42 21263 20 44637 8462 58 26 8 14 28 27 29 17 15 11 15989 20 31 29372 24638 19 27864 40789 40405 11 21336 8 15 5 ...

output:

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

result:

ok 50000 numbers

Test #12:

score: 30
Accepted
time: 39ms
memory: 7520kb

input:

46006
19 9 6 17 20 7 17 38505 39512 10 17 45828 7491 18 13 6 19 5 19 36171 13 17 2484 10 9 6324 18 38597 19 16 7 10 19 12 16 20 7 14 39395 24365 20 15 5 38579 11 39387 22 36513 9 17 17 16 4 32805 13 5 5 33142 14 13 9 15 12 12 6 3 19670 7 21 7 14 42124 7 3 6 11 12 17 14 17 5 17 24555 15 8 21 14 8 3 1...

output:

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

result:

ok 50000 numbers

Subtask #2:

score: 20
Accepted

Test #13:

score: 20
Accepted
time: 6ms
memory: 4060kb

input:

4681
11 7 2524 4128 1315 4444 205 750 3112 932 1690 3540 3647 461 3547 2873 1944 1617 1439 85 4106 3897 2853 6 3270 1159 1636 5 2966 4463 4288 688 1982 1274 4454 4270 3129 4255 118 4549 4266 7 7 1347 3638 1280 4022 2901 368 2238 3 2750 2987 3218 3507 6 1137 983 4327 2867 1155 2096 7 414 1564 10 1044...

output:

570
348
1395
2748
1171
1119
2183
3117
2050
2758
1122
1913
584
1188
2343
1766
3730
3166
997
112
836
563
210
2082
1852
2808
1686
2459
276
2143
2414
371
3031
1035
2437
3656
4405
100
3669
1905
383
2305
3089
2419
2316
2738
450
4080
1756
2657
524
1447
2444
79
694
366
2752
1291
1980
3039
518
790
855
2114
5...

result:

ok 5000 numbers

Test #14:

score: 20
Accepted
time: 6ms
memory: 4012kb

input:

4925
4861 1340 190 2462 10 1877 995 2715 3224 10 11 721 1270 393 3325 1038 3441 3844 3243 1169 873 1340 3620 685 3792 2 11 936 746 616 2699 1095 3220 3442 4192 1991 4003 1321 10 4894 34 3436 4 1818 812 4378 2433 2925 3834 4 2147 3625 4878 4526 5 4512 2328 1923 718 2577 1409 3041 4891 8 1795 4655 230...

output:

757
2842
2531
1042
1692
3292
3872
1781
31
311
1557
3079
2882
804
3596
4343
1883
1847
1055
2288
2996
720
1709
2117
299
1651
1621
79
2166
756
886
1507
255
158
611
2117
905
905
3713
1155
3721
2177
1763
3524
420
349
1424
452
479
3470
3179
1233
1202
559
533
1443
3936
239
3600
3830
1741
582
1804
414
213
2...

result:

ok 5000 numbers

Test #15:

score: 20
Accepted
time: 6ms
memory: 4056kb

input:

4643
14 19 10 22 7 13 5 18 19 2617 22 21 15 10 3921 13 10 9 20 2287 5 495 398 9 13 14 18 7 16 18 166 11 10 8 5 12 18 7 21 16 3 7 16 8 22 6 13 3930 13 6 20 12 5 18 8 2037 24 17 9 4115 9 8 5 1058 743 7 20 6 21 21 15 21 8 246 10 4090 18 21 14 573 19 6 2 11 18 8 22 8 19 16 7 15 10 13 20 15 21 21 3 10 13...

output:

3093
1892
3516
1211
148
1415
961
2318
1017
2466
54
3246
311
1415
1441
821
1777
2223
2044
4141
861
632
2182
1016
3859
388
3886
486
1296
857
2010
789
1719
379
1926
2517
3038
1619
4126
1728
2372
197
2172
827
324
2968
3158
1592
2879
2231
1409
1088
1130
2864
1959
2657
3475
2406
2537
705
2085
1254
1420
84...

result:

ok 5000 numbers

Test #16:

score: 20
Accepted
time: 6ms
memory: 4008kb

input:

4913
7 2493 3237 4408 1481 1660 175 1602 1672 2795 11 634 1755 2511 2258 1497 2 2950 3688 813 834 6 3625 1941 2914 3522 891 4107 3420 4254 4117 7 150 4199 1788 4908 9 225 4544 12 3942 1029 4246 1308 1225 107 991 3574 212 4206 4876 2323 4661 3975 2553 4085 3331 2013 2742 6 554 3506 3063 2782 8 3294 3...

output:

802
464
4654
3866
318
2774
4087
175
1454
781
4364
1534
1237
2925
148
635
27
194
160
1016
3052
2639
1591
71
3646
1809
858
1858
1414
203
602
910
2013
4004
1353
2290
2015
789
2279
711
129
174
1400
2505
920
1076
3774
573
2198
2882
4316
636
2586
25
1426
1645
251
454
1207
1391
330
1403
2515
2007
418
4410
...

result:

ok 5000 numbers

Test #17:

score: 20
Accepted
time: 6ms
memory: 3992kb

input:

4885
23 34 34 37 29 32 22 7 17 34 27 922 19 13 20 3116 23 11 1995 23 26 25 13 71 25 17 459 29 34 612 32 35 10 13 25 24 17 17 12 963 14 19 43 23 22 26 12 26 26 19 29 48 12 20 21 12 37 1590 25 26 1076 4770 8 9 13 26 16 31 27 16 1102 24 17 30 21 17 8 12 7 12 27 24 8 5 23 35 26 18 98 9 24 6 27 8 13 18 1...

output:

814
298
151
544
581
1455
574
1580
307
1036
1569
342
2452
3387
246
80
2445
400
41
435
286
461
2437
602
1542
9
2103
162
449
969
1434
1580
832
1873
793
4007
3194
2481
3900
386
3414
809
4090
3628
2691
2262
3168
3029
2130
2478
2494
648
1207
1955
1603
3737
1239
79
3356
2358
4122
625
1864
3103
2560
2758
15...

result:

ok 5000 numbers

Test #18:

score: 20
Accepted
time: 3ms
memory: 4112kb

input:

4572
19 4174 6 6 4 1787 20 10 14 16 7 3 12 1379 4272 5 11 15 17 14 11 13 10 6 22 3509 2225 282 13 3091 3237 15 1717 8 1214 20 6 4374 17 5 19 2573 14 21 2165 18 5 1929 12 19 4317 11 3976 9 11 20 18 2619 11 15 8 23 21 12 22 16 11 14 5 2572 8 14 12 3153 2 9 13 18 8 3704 19 16 7 22 19 27 16 19 3 5 10 13...

output:

32
5
1576
2622
2753
32
1796
1185
1214
3231
2129
131
393
3731
3666
644
1621
2681
584
921
192
256
680
1553
318
1427
222
2473
2585
1687
75
1168
2482
1412
1608
3130
1093
1021
907
903
210
2608
601
2192
2561
81
3209
2253
707
1558
1090
1345
2878
2052
2264
295
514
2345
1799
1461
1628
3449
1313
698
3581
1776...

result:

ok 5000 numbers

Test #19:

score: 20
Accepted
time: 6ms
memory: 4016kb

input:

4953
3137 4683 170 4567 11 1639 4818 3612 1890 2618 2999 964 3008 2675 2871 4783 2078 8 3453 4385 1125 5 1224 1645 3928 1738 3131 4122 2179 1868 4410 2131 2281 1114 11 2300 4 690 4686 3513 1215 1518 4 3157 2553 2722 3579 307 659 103 4103 3675 3430 33 3304 4528 4024 1918 4871 768 2713 1791 2009 2757 ...

output:

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

result:

ok 5000 numbers

Test #20:

score: 20
Accepted
time: 5ms
memory: 3980kb

input:

4699
4 3303 913 632 4451 1602 103 2601 253 3107 226 3650 9 827 2 2288 4491 3889 7 1082 4306 1643 3323 1520 3981 4586 10 1587 3072 6 842 1122 3600 550 1841 2533 1475 4647 3902 266 3 613 925 6 1884 5 2653 3 1511 5 1729 8 975 3351 1467 54 2322 11 499 3648 3363 3314 4114 1853 1124 4539 712 1129 868 3150...

output:

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

result:

ok 5000 numbers

Test #21:

score: 20
Accepted
time: 6ms
memory: 4072kb

input:

4697
18 9 6 2 4 5 7 12 13 7 3 10 4 22 7 16 8 15 9 17 3 4 6 14 19 10 7 535 13 12 2215 21 11 11 14 20 19 11 6 20 7 9 14 19 2724 6 16 21 13 19 13 3 1645 9 16 2256 10 2 10 16 5 8 4 2746 13 653 11 3 1197 20 6 2 23 25 5 15 14 9 12 3 9 12 3 7 6 13 19 16 3 1536 11 19 20 78 14 17 1189 9 11 17 14 18 18 9 3309...

output:

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

result:

ok 5000 numbers

Test #22:

score: 20
Accepted
time: 3ms
memory: 4076kb

input:

4946
3641 37 4095 7 2396 1463 14 11 2681 4248 3479 3962 4485 1177 409 4370 4423 1191 5 2992 4208 4833 3739 2741 2883 3948 762 8 4433 4360 1889 176 2326 11 4183 4916 365 2694 2559 3147 475 4195 4053 2383 3607 2917 19 4402 3565 2128 4709 435 1407 3697 868 3482 3698 169 1279 240 846 3768 1184 4850 2633...

output:

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

result:

ok 5000 numbers

Test #23:

score: 20
Accepted
time: 5ms
memory: 4028kb

input:

4751
4016 15 28 19 21 3 26 34 22 3352 3538 3928 3156 1790 17 24 16 26 4357 2340 15 7 24 39 6 14 13 36 20 21 3796 2585 2326 159 29 7 12 8 4730 1267 16 12 28 62 16 14 27 29 7 26 3 17 45 8 22 3707 27 12 22 42 4303 22 3821 41 3 11 19 31 6 21 9 3 22 6 15 22 26 3 347 20 28 23 6 3102 1861 16 17 32 14 20 12...

output:

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

result:

ok 5000 numbers

Test #24:

score: 20
Accepted
time: 5ms
memory: 4120kb

input:

4547
8 18 8 19 3411 13 746 13 18 13 10 11 5 15 1095 21 16 17 17 9 770 15 1990 16 3680 23 9 12 3 5 22 4 4186 23 21 931 14 968 1049 20 16 3609 15 5 6 20 11 21 12 13 21 1443 8 2 1588 18 3706 17 18 7 5 15 20 1852 4 9 2 20 13 3025 7 18 12 19 11 15 10 11 2885 13 21 20 18 10 9 14 11 11 2968 21 21 4 21 20 1...

output:

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

result:

ok 5000 numbers

Subtask #3:

score: 50
Accepted

Test #25:

score: 50
Accepted
time: 2755ms
memory: 151028kb

input:

1927935
1307002 177803 328035 1844109 5 532876 1638997 1111173 1392421 1704007 241552 613377 262779 4 1823788 394795 52876 11 8 1103445 1293860 1033234 1745826 249295 670713 1452644 1891635 331608 933251 1531742 559293 291541 732326 969795 1592807 8 1358796 1389801 1074221 1709205 945430 726546 1488...

output:

727848
1026164
1233157
552414
388215
432549
74976
700049
8114
452986
612727
137410
933681
469413
253893
451868
899632
25552
1341718
1197525
744045
198241
186021
635522
875168
424572
1846217
952996
808896
843010
89400
864211
402012
167625
283143
1010291
113288
259012
549760
67737
1259387
1780006
1565...

result:

ok 2000000 numbers

Test #26:

score: 50
Accepted
time: 2629ms
memory: 152244kb

input:

1920751
920500 536028 1546243 16616 1615410 1817369 1029410 985982 785136 10 1789611 1889648 2 11 3 696751 2 1587197 555790 1910131 414352 698880 748493 6 569885 1548521 110195 444544 1633266 1121887 373205 8 1915168 11 1742126 1574428 218862 819746 658129 1382274 8 282730 1882887 77497 1322317 6156...

output:

858931
69239
59761
401815
462638
221568
910003
1108749
226194
437645
1397604
1569102
126874
740337
86683
838237
487946
769405
443149
112142
422778
676546
1035901
11972
167039
1275098
161746
115879
427851
994928
48161
1381471
37236
1282450
929330
71080
776866
1174589
900193
130872
169868
1072505
7993...

result:

ok 2000000 numbers

Test #27:

score: 50
Accepted
time: 2521ms
memory: 153044kb

input:

1971080
1332735 4 4 1693111 19 3 13 15 637778 14 7 13 3 12 21 13 5 17 17 18 18 9 20 6 503164 17 7 13 10 15 3 2 16 6 1766123 20 8 16 19 4 17 3 6 20 4 17 13 12 21 2 723464 17 14 14 10 518405 6 13 15 10 2 7 722206 6 20 2 2 12 1542681 7 466800 10 17 16 11 4 2 654140 19 14 20 17 10 6 6 11 10 1893965 7 6 ...

output:

1488400
1049040
500590
1134634
1341969
617684
864357
693800
243309
1753250
1205043
928114
1062044
1626220
819178
155434
833647
1465641
287384
1116588
1167800
34427
770741
1339342
1407858
614855
981642
628077
356497
958215
1462565
941767
34544
582897
332076
508006
878646
904123
1077109
70721
967857
2...

result:

ok 2000000 numbers

Test #28:

score: 50
Accepted
time: 2458ms
memory: 146072kb

input:

1990229
1 1 1 1 1 2 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 ...

output:

1604
1604
1390
655
655
1746
655
17299
655
1975
655
655
1390
655
655
655
1746
1604
1975
1604
655
655
655
1746
283
655
655
655
1975
655
1746
655
1746
655
1604
840
1604
655
1604
1604
655
1525
655
655
1525
655
428
655
655
655
49
923
655
4
10519
2182
1975
1604
106
1525
655
1604
655
1975
1975
655
1604
655...

result:

ok 2000000 numbers

Test #29:

score: 50
Accepted
time: 2502ms
memory: 146960kb

input:

1959221
2 1 2 1 6 3 2 1 1 1 3 2 3 1 1 1 3 1 4 1 1 1 4 4 3 1 1 3 1 1 1 1 1 5 2 2 2 1 1 1 2 2 1 1 3 1 2 3 2 2 2 1 1 3 1 1 1 2 2 1 1 1 2 3 1 1 3 1 3 1 2 2 2 1 3 1 2 1 2 4 1 2 1 2 3 1 4 1 6 1 1 1 2 3 3 1 1 1 3 2 4 3 2 1 1 1 1 1 1 1 2 1 1 1 2 2 1 1 1 1 1 1 2 3 2 1 1 1 3 1 1 1 2 2 3 5 1 1 1 1 1 1 1 1 2 1 ...

output:

296071
71046
379891
296071
19844
2257
71046
274777
9950
36857
71046
71046
71046
379891
296071
71046
19844
36857
71046
19844
71046
71046
379891
832233
105115
296071
71046
30888
26183
9389
296071
19844
296071
296071
296071
19844
8195
401078
296071
50053
379891
379891
36857
296071
71046
190957
8576
198...

result:

ok 2000000 numbers

Test #30:

score: 50
Accepted
time: 2590ms
memory: 145668kb

input:

1951696
1 19 6 16 14 5 4 17 1 5 4 9 25 3 7 11 4 7 6 17 13 2 17 6 5 13 13 26 8 8 6 12 3 5 5 31 4 2 10 4 16 9 5 12 2 4 1 7 1 15 2 3 15 11 6 13 1 10 22 9 2 10 11 22 2 11 16 3 3 13 5 11 27 10 1 11 7 4 4 7 4 32 8 1 8 5 13 5 3 11 31 6 7 2 18 5 19 2 20 21 4 13 18 35 2 2 12 10 56 4 16 1 15 22 16 30 10 2 6 2...

output:

1259302
30913
108683
177732
265197
1120238
972388
1385434
140559
691341
769632
145540
715866
4676
16875
320846
79740
336255
946731
69223
64884
84342
587792
1120238
992413
1259302
972388
31950
95162
1073276
404373
972388
862604
57782
378733
564796
504436
204252
230012
139447
972388
1259302
598008
308...

result:

ok 2000000 numbers

Test #31:

score: 50
Accepted
time: 2692ms
memory: 152820kb

input:

1954831
1460820 642886 1400144 1724206 1892530 249827 664060 933901 528572 7 1565627 1882957 1431730 1609138 1892708 181867 1716316 412797 251975 1629084 609624 1307847 325204 1611812 11 1251621 2 5 562368 1325356 1071375 957926 10 621323 1001729 342890 1250925 1361774 5 1559943 974987 945975 913802...

output:

1473137
1470304
1262134
614642
172285
1578752
183709
1313039
1149702
763142
1604789
307314
724666
449756
638467
484265
1246085
941077
974780
26855
411660
327340
182437
726543
919815
487906
238788
223080
1233254
106661
652002
193688
1009695
1268431
411882
244787
854738
120548
460492
500372
931913
961...

result:

ok 2000000 numbers

Test #32:

score: 50
Accepted
time: 2699ms
memory: 153376kb

input:

1958076
8 1112387 1754732 4 1513627 9 403766 4 1205477 8 9 1496030 736022 1036819 1540962 1647647 389852 7 9 9 1407000 974881 1515412 871805 410654 308839 1318274 1220586 1039934 1298242 470154 258339 1313801 231053 1056471 740512 1204616 684133 8 1229417 4 1423896 6 981953 1639669 10 797822 479699 ...

output:

297833
1015856
523739
74699
64833
1894823
565211
1172869
1676611
458356
705755
41192
1726454
516150
153073
1590505
319511
760493
73551
809587
513344
1564746
75890
352544
401412
173532
983987
77428
87185
746241
266822
64509
12681
259841
214377
875384
1161060
1462113
223612
79501
387680
296209
458360
...

result:

ok 2000000 numbers

Test #33:

score: 50
Accepted
time: 2447ms
memory: 152488kb

input:

1932879
14 12 7 21 7 19 16 11 15 1581908 1834084 2 6 5 11 1119125 11 3 14 18 15 12 9 389947 11 6 12 8 2 3 8 339479 17 1178106 17 1270421 4 16 18 18 3 17 16 7 16 9 1331755 2 10 23 8 145335 15 7 9 14 20 21 11 22 20 12 5 7 9 1126509 12 20 18 2 16 25 2 13 1647030 4 7 231945 19 4 15 2 1681945 13 14 25 98...

output:

461721
90939
158100
934413
218377
412102
1138644
888884
52922
1638273
189385
198350
95112
530583
945397
1613399
969139
206284
196241
74172
782098
365062
359490
404034
1329746
768665
749149
1203298
855894
974710
1489688
9311
556029
23977
1093220
17168
672883
875710
177273
66362
364889
367304
1298735
...

result:

ok 2000000 numbers

Test #34:

score: 50
Accepted
time: 2702ms
memory: 153652kb

input:

1975351
744596 1092916 492550 1227150 436349 1294472 846315 751602 11 1964091 899113 27430 286628 818210 1128023 1149109 80803 1027422 102766 1645620 614244 1223785 922059 1547319 397631 1876740 897202 1509453 604673 788566 1376791 1974854 1275517 428122 1967415 54916 1221096 1037258 1098063 1304266...

output:

129382
256827
74360
487546
658083
21662
27501
143190
84792
765129
1378608
489601
426460
187564
268485
520069
147768
233852
379355
575114
965286
967069
233890
822231
1214842
385090
551682
461170
339061
1365409
1168662
1723611
646211
67896
551356
258629
375889
260129
716229
903073
1625309
399769
37724...

result:

ok 2000000 numbers

Test #35:

score: 50
Accepted
time: 2478ms
memory: 156244kb

input:

1948732
893055 18 10 39 18 33 11 24 1260989 19 1139467 9 893199 1123259 7 13 24 16 19 846494 1563627 20 179869 18 10 16 22 15 11 16 42 904371 21 30 25 27 11 26 9 46445 1127833 6 35 1418990 240304 192662 30 10 29 20 20 17 7 18 10 1286294 37 21 16 1593178 30 21 6 10 33 7 29 21 659603 47 21 20 15 12 16...

output:

378852
1541954
20700
650490
1145520
781073
354502
340970
515903
1079459
1635601
1461904
46788
792856
998454
25424
467342
601531
44485
652375
126976
70914
413126
1067739
50201
1054057
330363
872442
524060
819276
310177
383662
450177
751801
648369
139277
377559
195306
18643
310592
407086
302527
586788...

result:

ok 2000000 numbers

Test #36:

score: 50
Accepted
time: 2454ms
memory: 155740kb

input:

1960173
18 9 16 21 10 15 14 19 19 19 17 21 12 11 11 851107 10 1186733 3 4 11 8 8 7 19 1754263 922095 19 8 11 8 11 241278 20 2 271992 12 8 15 19 13 20 19 78059 20 6 1220730 588951 1876914 21 1916633 273806 19 7 8 16 23 252632 1571726 3 787137 17 17 6 301765 818530 5 19 866687 124819 1591311 22 12 12 ...

output:

134747
879580
1630186
1153623
703961
27471
406749
612676
817056
1457897
337768
585316
341421
249737
587626
720116
827310
354008
959930
233244
130294
723277
1070702
995234
827676
398998
302310
1255773
659498
1015778
54590
535706
778832
38688
454745
322414
974039
680587
1635612
147738
132319
758458
26...

result:

ok 2000000 numbers

Test #37:

score: 50
Accepted
time: 2425ms
memory: 156692kb

input:

1951237
1537521 1439720 10 734083 1656454 1796345 1567675 1764028 8 367619 57510 1513482 888945 289672 637318 517636 2 480382 192789 452300 1712305 154959 240134 8 272213 1380356 1824176 691713 664421 1920215 663406 501590 46033 1935651 572833 1557992 518644 1809034 164430 322476 964660 1026061 6490...

output:

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

result:

ok 2000000 numbers

Test #38:

score: 50
Accepted
time: 2381ms
memory: 158468kb

input:

1911588
1284762 1618844 540636 4 1371824 455400 7 11 1005922 1439580 819850 1468715 4 1817508 9 1173918 922145 228430 302996 832716 1866058 6 816401 1589142 285130 10 913598 1086492 1012968 10 441923 121637 508391 1326452 2 1304858 414872 11 96633 3 703637 729157 7 308605 1354645 1768308 208779 4 16...

output:

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

result:

ok 2000000 numbers

Test #39:

score: 50
Accepted
time: 2128ms
memory: 158180kb

input:

1902158
22 8 10 17 4 18 17 310800 17 21 18 17 13 5 8 13 16 1377957 5 23 8 14 6 384007 22 10 21 12 27325 7 21 20 13 22 11 5 5 7 9 2 19 949748 4 9 337407 24 524177 9 18 1817734 1637190 16 751368 4 13 9 3 14 12 5 10 21 10 19 19 20 14 15 14 3 8 9 5 15 7 12 5 19 5 12 13 1388880 11 9 545591 22 22 9 14 4 1...

output:

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

result:

ok 2000000 numbers

Test #40:

score: 50
Accepted
time: 2407ms
memory: 157848kb

input:

1925513
1860627 796014 403018 1081322 492067 8 1814913 1409689 312605 684213 760703 1329788 1352811 458701 1192017 281944 9 1599408 292738 450398 9 400678 1222157 951891 4 134907 159414 63345 16597 400767 7 1548805 1581481 1355547 1326423 617383 955456 613739 1176689 688248 1601112 1866896 1895313 1...

output:

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

result:

ok 2000000 numbers

Test #41:

score: 50
Accepted
time: 2138ms
memory: 159536kb

input:

1944559
24 35 651054 29 10 21 4 10 1554959 41 745834 12 21 1493717 24 25 13 3 26 18 26 25 24 27 10 30 27 971988 18 24 26 10 3 16 18 29 26 12 17 4 12 20 12 6 21 58284 20 12 9 13 23 43 28 296245 41 44 1216142 10 17 15 17 618312 39 33 1242859 1667068 49 60 7 24 29 16 1589423 10 27 20 7 8 121268 25 25 7...

output:

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

result:

ok 2000000 numbers

Test #42:

score: 50
Accepted
time: 2161ms
memory: 158484kb

input:

1998999
955383 19 10 14 22 13 17 1728084 6 13 20 1830867 11 13 24 2 1667135 10 22 6 987716 19 11 18 6 5 3 13 20 12 20 15 210174 11 13 53626 10 5 7 17 447314 19 1646371 3 11 6 4 13 23 4 1796205 3 5 14 18 1876671 8 10 15 24 22 5 20 16 13 1466910 4 21 589262 14 1991500 1383075 15 14 1902153 2 4 13 17 5...

output:

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

result:

ok 2000000 numbers

Extra Test:

score: 0
Extra Test Passed