QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398818#2560. Streetlightszjy0001TL 4310ms69000kbC++142.8kb2024-04-25 18:36:542024-04-25 18:36:56

Judging History

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

  • [2024-04-25 18:36:56]
  • 评测
  • 测评结果:TL
  • 用时:4310ms
  • 内存:69000kb
  • [2024-04-25 18:36:54]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
#define LLL __int128
#define uint unsigned
#define ldb long double
#define uLL unsigned long long
using namespace std;
const int N=1e5+5,M=2.5e5+5,INF=1e9;
int n,q,a[N],A[N],b[N+M],ans[M];
set<int>pre[N+M],suf[N+M];
int Fa[N+M],Fb[N+M],Ta[(N+M)*4],Tb[(N+M)*4],S[(N+M)*4];
inline int qry(int p,int l,int r,int a,int b){
    if(Fa[r]<=a&&Fb[r]<=b)return S[p];
    if(a<Ta[p]||b<Tb[p])return 0;
    const int mid=(l+r)>>1;
    if(Ta[p*2+1]<=a&&Tb[p*2+1]<=b)return qry(p*2+1,mid+1,r,a,b)+S[p]-S[p*2+1];
    else return qry(p*2,l,mid,min(a,Ta[p*2+1]),min(b,Tb[p*2+1]));
}
inline void build(int p,int l,int r){
    if(l==r){
        Ta[p]=(Fa[l]=pre[l].empty()?INF:*pre[l].begin());
        Tb[p]=(Fb[l]=suf[l].empty()?INF:*suf[l].begin());
        S[p]=1;
        return;
    }
    const int mid=(l+r)>>1;
    build(p*2,l,mid),build(p*2+1,mid+1,r);
    Ta[p]=min(Ta[p*2],Ta[p*2+1]),Tb[p]=min(Tb[p*2],Tb[p*2+1]);
    S[p]=S[p*2+1]+qry(p*2,l,mid,Ta[p*2+1],Tb[p*2+1]);
}
inline void upd(int p,int l,int r,int x){
    if(l==r){
        Ta[p]=(Fa[l]=pre[l].empty()?INF:*pre[l].begin());
        Tb[p]=(Fb[l]=suf[l].empty()?INF:*suf[l].begin());
        S[p]=1;
        return;
    }
    const int mid=(l+r)>>1;
    x<=mid?upd(p*2,l,mid,x):upd(p*2+1,mid+1,r,x);
    Ta[p]=min(Ta[p*2],Ta[p*2+1]),Tb[p]=min(Tb[p*2],Tb[p*2+1]);
    S[p]=S[p*2+1]+qry(p*2,l,mid,Ta[p*2+1],Tb[p*2+1]);
}
inline void solve(int l,int r,vector<tuple<int,int,int>>&Q){
    if(l>=r)return;
    const int mid=(l+r)>>1;
    int m=r-l+1;
    copy(a+l,a+r+1,b+1);
    vector<tuple<int,int,int>>nQ;
    for(auto&[x,y,id]:Q)if(l<=x&&x<=r)nQ.emplace_back(x,y,id),b[++m]=y;
    sort(b+1,b+m+1);
    for(int i=l;i<=r;++i)
        A[i]=lower_bound(b+1,b+m+1,a[i])-b,
        (i<=mid?pre[A[i]]:suf[A[i]]).emplace(i<=mid?-i:i);
    build(1,1,m);
    int lans=qry(1,1,m,-l,r);
    ans[0]+=lans;
    for(auto [x,y,id]:nQ){
        y=lower_bound(b+1,b+m+1,y)-b;
        int z=A[x];
        if(y!=z){
            ans[id]-=lans;
            if(x<=mid)pre[z].erase(-x),pre[y].emplace(-x);
            else suf[z].erase(x),suf[y].emplace(x);
            A[x]=y,upd(1,1,m,z),upd(1,1,m,y);
            ans[id]+=(lans=qry(1,1,m,-l,r));
        }
    }
    for(int i=1;i<=m;++i)pre[i].clear(),suf[i].clear();
    Q=nQ,solve(l,mid,Q),solve(mid+1,r,nQ);
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    // freopen("tower.in","r",stdin);
    // freopen("tower.out","w",stdout);
    cin>>n>>q;
    vector<tuple<int,int,int>>Q;
    for(int i=1;i<=n;++i)cin>>a[i];
    for(int i=1;i<=q;++i){
        int x,y;cin>>x>>y,Q.emplace_back(x,y,i);
    }
    solve(1,n,Q);
    for(int i=0;i<=q;++i)
        cout<<ans[i]<<'\n',ans[i+1]+=ans[i];
    return 0;
}
/*
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 2
4 2 2 2 4 6
4 6
6 4

output:

3
2
2

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 8ms
memory: 36688kb

input:

50 100
310081863 722273055 654741011 310081863 654741011 722273055 654741011 722273055 654741011 654741011 654741011 310081863 310081863 722273055 654741011 654741011 654741011 722273055 310081863 654741011 310081863 310081863 310081863 722273055 310081863 654741011 654741011 310081863 722273055 722...

output:

28
28
28
29
30
31
31
31
31
31
31
31
31
32
33
34
34
33
33
33
33
32
32
31
31
31
32
32
31
31
31
31
30
30
30
31
31
31
31
31
31
30
30
29
30
31
32
32
32
32
32
31
32
33
33
33
33
32
32
31
32
33
31
31
32
31
32
31
31
31
30
31
30
29
29
28
28
29
28
28
27
27
27
27
27
27
26
27
28
27
28
29
28
28
28
28
29
29
28
29
28

result:

ok 101 lines

Test #3:

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

input:

50 100
93308794 275481889 130830018 675774101 130830018 93308794 275481889 999873895 275481889 104418887 130830018 275481889 675774101 999873895 130830018 841188804 360486542 104418887 140762403 275481889 275481889 770511267 104418887 140762403 93308794 675774101 104418887 770511267 130830018 933087...

output:

12
12
11
11
11
11
11
11
10
10
10
10
10
10
10
11
11
11
11
12
12
12
12
12
11
10
11
11
11
11
11
12
13
12
12
13
13
14
12
11
11
10
10
10
10
10
9
9
9
9
9
9
8
9
10
10
9
10
9
9
9
10
10
11
12
12
13
13
13
13
14
14
13
13
13
12
12
12
12
13
12
12
12
12
12
12
13
13
13
13
15
15
15
17
18
18
17
17
16
16
15

result:

ok 101 lines

Test #4:

score: 0
Accepted
time: 4ms
memory: 36428kb

input:

50 100
195248019 905127308 129122336 764519854 338556860 795943323 554412442 338556860 217191782 140699690 654772489 386182517 217191782 37485244 795943323 924638428 795943323 820028162 855279832 795943323 129122336 554412442 195248019 764519854 810525122 554412442 201706134 661330059 129122336 2090...

output:

5
5
6
5
5
5
4
4
3
3
3
3
3
2
4
3
3
3
4
5
5
5
5
5
5
5
5
4
4
4
5
6
6
5
5
4
4
4
3
3
3
3
3
3
4
4
4
4
3
3
4
3
3
3
3
3
3
3
3
3
3
3
4
4
4
4
4
5
5
5
5
6
6
6
5
5
5
5
5
6
6
6
6
7
7
7
7
7
7
7
7
7
7
7
7
7
7
8
8
8
7

result:

ok 101 lines

Test #5:

score: 0
Accepted
time: 8ms
memory: 36500kb

input:

50 100
772094573 19576803 263817454 873867094 557813690 952336439 500513802 392057352 305209480 199018938 206776586 514630037 466387810 403552086 50423285 658534934 19576803 404488754 179660945 591777562 262850065 817419372 680762089 591777562 424021147 403552086 718896141 456431927 680762089 595426...

output:

1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
0
0
0
0
0
1
1
1
1
1
1
0
0
0
0
1
2
2
2
3
3
3
3
3
3
2
2
2
2
2
2
2
1
1
1
0
0
0
0
0
0
0
0
0
1
2
2
3
3
3
3
3
3
2
2
2
3
3
3
3
3
3
3

result:

ok 101 lines

Test #6:

score: 0
Accepted
time: 8ms
memory: 36436kb

input:

50 100
5096114 61078240 254964021 318250156 571031769 256037951 208426954 833646260 732869624 746606948 226729785 151221431 611264696 351005299 205027954 706057630 453231547 874058912 462474957 366832522 823051853 289489922 109072951 103985450 269915659 377686154 809672410 12123621 732787174 9017273...

output:

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

result:

ok 101 lines

Test #7:

score: 0
Accepted
time: 8ms
memory: 36740kb

input:

50 100
976187983 976187983 879080743 976187983 827737130 827737130 827737130 827737130 815905933 811453113 789018592 789018592 681089922 675640665 659464656 635119734 635119734 633485638 633485638 567930339 552957008 484438465 484438465 484438465 387753272 377659696 376161946 976187983 367642977 376...

output:

16
15
14
14
15
16
17
17
18
18
31
30
29
28
27
26
25
24
23
22
21
20
20
19
20
19
18
18
18
18
18
17
17
16
16
16
16
15
15
15
15
14
13
12
12
12
12
11
11
10
9
9
9
8
8
7
7
6
7
6
7
7
7
8
8
7
8
10
10
10
10
10
11
10
10
12
14
15
15
16
16
15
16
18
19
20
26
26
27
28
29
28
28
27
26
25
24
23
23
22
21

result:

ok 101 lines

Test #8:

score: 0
Accepted
time: 4ms
memory: 36484kb

input:

50 100
843864537 245114944 227661173 137675097 918583745 80278395 44678681 37169219 37007425 27167524 4382795 4043558 3655016 3624538 2994987 1979195 1407769 819862 771067 665903 137891 137891 665903 771067 819862 1407769 1979195 2994987 3624538 3655016 4043558 4382795 27167524 37007425 37142735 305...

output:

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

result:

ok 101 lines

Test #9:

score: 0
Accepted
time: 8ms
memory: 36492kb

input:

50 100
920202355 768392166 755066475 630812635 617367313 601334965 450742259 367726734 265094786 151773018 77676966 53524889 53524889 77676966 151773018 265094786 205222950 154745305 57476426 57476426 154745305 294856628 367726734 450742259 601334965 617367313 630812635 481253037 481253037 755066475...

output:

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

result:

ok 101 lines

Test #10:

score: 0
Accepted
time: 2511ms
memory: 64692kb

input:

100000 250000
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

output:

99296
99297
99298
99299
99301
99302
99304
99306
99307
99308
99310
99312
99313
99314
99315
99317
99318
99319
99320
99321
99322
99323
99324
99326
99327
99329
99330
99332
99333
99334
99335
99337
99338
99339
99341
99343
99345
99347
99348
99349
99350
99351
99353
99354
99355
99356
99357
99358
99359
99360
...

result:

ok 250001 lines

Test #11:

score: 0
Accepted
time: 2374ms
memory: 69000kb

input:

100000 250000
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

output:

99990
99982
99981
99985
99990
99986
99985
99989
99990
99989
99982
99983
99990
99987
99984
99985
99990
99985
99984
99985
99990
99982
99981
99984
99990
99988
99985
99986
99990
99986
99981
99982
99990
99982
99981
99986
99990
99987
99984
99985
99990
99982
99981
99984
99990
99983
99981
99982
99990
99989
...

result:

ok 250001 lines

Test #12:

score: 0
Accepted
time: 2285ms
memory: 68652kb

input:

100000 250000
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

output:

99990
99988
99987
99989
99990
99984
99981
99982
99990
99986
99981
99982
99990
99989
99985
99986
99990
99987
99980
99981
99990
99985
99981
99982
99990
99985
99982
99983
99990
99986
99983
99984
99990
99987
99985
99986
99990
99989
99984
99985
99990
99985
99981
99982
99990
99983
99982
99989
99990
99987
...

result:

ok 250001 lines

Test #13:

score: 0
Accepted
time: 1772ms
memory: 67904kb

input:

100000 250000
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

output:

99990
99988
99980
99981
99990
99988
99987
99989
99990
99985
99984
99985
99990
99988
99984
99985
99990
99988
99987
99989
99990
99985
99982
99983
99990
99983
99982
99984
99990
99982
99981
99988
99990
99987
99981
99982
99990
99986
99983
99984
99990
99983
99982
99986
99990
99981
99980
99983
99990
99989
...

result:

ok 250001 lines

Test #14:

score: 0
Accepted
time: 2663ms
memory: 66048kb

input:

100000 250000
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

output:

99990
99985
99980
99981
99990
99983
99982
99983
99990
99983
99982
99989
99990
99983
99982
99983
99990
99989
99985
99986
99990
99989
99985
99986
99990
99985
99980
99981
99990
99984
99981
99982
99990
99984
99983
99987
99990
99989
99981
99982
99990
99989
99984
99985
99990
99985
99984
99989
99990
99989
...

result:

ok 250001 lines

Test #15:

score: 0
Accepted
time: 841ms
memory: 52280kb

input:

100000 85453
662004428 662004428 662004428 662004428 285389268 662004428 662004428 662004428 662004428 662004428 662004428 662004428 662004428 662004428 662004428 662004428 662004428 662004428 285389268 662004428 662004428 662004428 285389268 662004428 662004428 285389268 662004428 662004428 6620044...

output:

87530
87530
87529
87528
87528
87527
87527
87526
87525
87525
87524
87523
87522
87523
87523
87523
87522
87521
87520
87519
87519
87518
87517
87516
87515
87514
87513
87512
87511
87510
87510
87509
87509
87508
87507
87507
87507
87506
87505
87504
87503
87503
87502
87501
87500
87499
87498
87497
87496
87496
...

result:

ok 85454 lines

Test #16:

score: 0
Accepted
time: 1617ms
memory: 53848kb

input:

100000 130170
687775446 687775446 687775446 687775446 687775446 687775446 687775446 687775446 687775446 687775446 687775446 687775446 66131936 687775446 687775446 153170868 687775446 687775446 153170868 687775446 153170868 687775446 687775446 687775446 687775446 687775446 687775446 687775446 6877754...

output:

82091
82091
82090
82089
82088
82087
82086
82085
82084
82083
82082
82081
82080
82079
82079
82079
82078
82077
82076
82075
82074
82074
82073
82072
82071
82070
82069
82068
82067
82066
82065
82064
82065
82065
82064
82063
82062
82061
82060
82059
82058
82057
82056
82055
82055
82054
82054
82054
82053
82053
...

result:

ok 130171 lines

Test #17:

score: 0
Accepted
time: 2286ms
memory: 64644kb

input:

100000 250000
986692197 986692197 986692197 986692197 986692197 986692197 986692197 986692197 986692197 986692197 986692197 986692197 986692197 986692197 986692197 986692197 286706529 263144019 263144019 513324265 986692197 986692197 986692197 986692197 263144019 112713891 986692197 986692197 986692...

output:

72113
72112
72111
72110
72110
72109
72108
72107
72106
72106
72106
72106
72105
72104
72104
72103
72103
72103
72102
72101
72101
72100
72099
72098
72097
72096
72095
72094
72093
72092
72091
72090
72090
72090
72089
72089
72088
72088
72088
72088
72087
72086
72085
72084
72083
72082
72081
72080
72079
72078
...

result:

ok 250001 lines

Test #18:

score: 0
Accepted
time: 3211ms
memory: 64676kb

input:

100000 250000
259412947 915441273 915441273 915441273 915441273 915441273 915441273 915441273 41568879 915441273 41568879 915441273 915441273 915441273 915441273 915441273 915441273 915441273 915441273 915441273 915441273 786625775 915441273 915441273 915441273 915441273 915441273 915441273 91544127...

output:

70293
70292
70291
70291
70290
70289
70288
70287
70287
70286
70286
70285
70284
70283
70282
70281
70280
70279
70278
70278
70278
70277
70276
70276
70275
70275
70274
70274
70273
70273
70273
70272
70271
70270
70269
70268
70267
70266
70265
70264
70263
70262
70261
70260
70259
70258
70257
70256
70256
70255
...

result:

ok 250001 lines

Test #19:

score: 0
Accepted
time: 2769ms
memory: 64696kb

input:

100000 250000
972766086 972766086 972766086 235311221 972766086 730052587 972766086 194240551 173272584 972766086 832962158 730052587 972766086 972766086 730052587 972766086 972766086 972766086 972766086 173272584 972766086 962996883 972766086 972766086 972766086 972766086 304469796 972766086 972766...

output:

69540
69539
69538
69538
69537
69536
69536
69535
69534
69534
69533
69532
69531
69530
69530
69531
69531
69531
69530
69530
69529
69528
69527
69527
69526
69525
69524
69524
69523
69522
69521
69520
69519
69518
69517
69516
69515
69514
69513
69513
69512
69512
69511
69510
69509
69508
69507
69506
69506
69506
...

result:

ok 250001 lines

Test #20:

score: 0
Accepted
time: 2912ms
memory: 64648kb

input:

100000 250000
154807547 918756403 953813422 619806450 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 420454628 953813422 866134938 953813422 953813422 953813422 360533231 20081630 953813422 953813422 953813422 953813422 953813422 9538134...

output:

68574
68574
68574
68573
68572
68571
68570
68569
68569
68568
68567
68566
68566
68565
68564
68563
68562
68561
68560
68559
68558
68557
68556
68556
68556
68556
68555
68555
68555
68555
68554
68554
68553
68553
68553
68552
68551
68550
68549
68548
68547
68546
68545
68544
68543
68543
68542
68542
68542
68542
...

result:

ok 250001 lines

Test #21:

score: 0
Accepted
time: 2906ms
memory: 64720kb

input:

100000 250000
852602535 249311522 976091974 627509820 64210097 976091974 976091974 976091974 617299575 976091974 349688741 118611971 581831340 976091974 555461910 434601718 976091974 976091974 976091974 64210097 976091974 976091974 976091974 765558531 976091974 976091974 976091974 976091974 97609197...

output:

67872
67871
67870
67869
67869
67868
67868
67867
67867
67866
67865
67865
67865
67864
67863
67863
67862
67861
67860
67859
67858
67857
67856
67855
67854
67853
67853
67854
67853
67852
67851
67850
67849
67849
67848
67847
67846
67845
67844
67844
67843
67844
67843
67842
67841
67840
67840
67839
67838
67837
...

result:

ok 250001 lines

Test #22:

score: 0
Accepted
time: 3236ms
memory: 64752kb

input:

100000 250000
984228313 984228313 984228313 984228313 984228313 984228313 740791129 984228313 984228313 140209594 984228313 984228313 984228313 379857068 984228313 984228313 984228313 867403878 680442778 984228313 680442778 984228313 365412827 965277635 984228313 984228313 984228313 984228313 984228...

output:

67031
67030
67030
67029
67029
67028
67027
67026
67025
67024
67024
67023
67023
67022
67021
67020
67020
67019
67018
67018
67017
67016
67015
67014
67013
67012
67011
67011
67010
67009
67009
67008
67007
67006
67005
67005
67004
67004
67003
67002
67002
67002
67002
67001
67001
67001
67000
66999
66998
66997
...

result:

ok 250001 lines

Test #23:

score: 0
Accepted
time: 2970ms
memory: 64712kb

input:

100000 250000
715257169 997296570 997296570 542312762 997296570 997296570 27873846 302224626 87347482 997296570 401624705 471054633 829392280 997296570 997296570 846504156 789999894 997296570 745260120 997296570 997296570 772173017 997296570 997296570 11575993 198643972 997296570 997296570 43349906 ...

output:

66442
66441
66441
66440
66439
66438
66438
66437
66437
66436
66435
66435
66434
66433
66433
66432
66431
66430
66430
66429
66428
66427
66427
66427
66426
66425
66424
66423
66423
66422
66421
66420
66420
66419
66419
66419
66418
66418
66417
66416
66416
66415
66414
66413
66412
66411
66411
66410
66410
66409
...

result:

ok 250001 lines

Test #24:

score: 0
Accepted
time: 3565ms
memory: 64732kb

input:

100000 250000
999986079 999986079 999986079 999986079 103890029 999986079 999986079 999986079 999986079 650871372 999986079 292720648 974802302 999986079 999986079 999986079 999986079 26228771 294305020 290616853 999986079 999986079 999986079 999986079 999986079 461483689 436031264 999986079 9999860...

output:

66681
66680
66680
66679
66679
66678
66677
66677
66676
66675
66674
66674
66674
66673
66673
66672
66671
66671
66671
66671
66670
66669
66668
66667
66666
66665
66664
66664
66664
66664
66663
66662
66661
66661
66660
66660
66659
66658
66657
66657
66656
66656
66655
66654
66653
66652
66651
66650
66649
66648
...

result:

ok 250001 lines

Test #25:

score: 0
Accepted
time: 4133ms
memory: 64816kb

input:

100000 250000
999956035 999956035 999956035 975343702 276311040 526419381 764599436 999956035 999956035 119568539 999956035 845700142 999956035 321583982 999956035 402892072 314737338 999956035 107619066 807964020 90604722 999956035 999956035 438108578 999956035 999956035 392747420 999956035 4271003...

output:

66891
66891
66890
66890
66890
66890
66889
66888
66887
66887
66887
66887
66886
66885
66885
66884
66883
66883
66882
66882
66881
66880
66880
66879
66878
66877
66876
66875
66874
66873
66873
66872
66871
66871
66870
66869
66868
66867
66867
66867
66866
66865
66864
66863
66863
66863
66862
66862
66861
66860
...

result:

ok 250001 lines

Test #26:

score: 0
Accepted
time: 4003ms
memory: 64716kb

input:

100000 250000
768126538 337685990 999958418 711799067 999958418 999958418 350680706 999958418 999958418 603135203 999958418 999958418 999958418 158588521 999958418 999958418 999958418 999958418 604529317 725404484 999958418 999958418 999958418 999958418 999958418 999958418 794883357 673444118 561480...

output:

66857
66856
66856
66855
66854
66853
66852
66852
66851
66850
66849
66848
66847
66846
66846
66845
66844
66843
66842
66841
66841
66840
66839
66838
66838
66838
66837
66836
66835
66834
66833
66833
66833
66832
66831
66830
66829
66828
66827
66827
66827
66826
66825
66824
66823
66822
66821
66820
66819
66818
...

result:

ok 250001 lines

Test #27:

score: 0
Accepted
time: 3954ms
memory: 64656kb

input:

100000 250000
999999981 999999981 999999981 999999981 699071796 873377350 999999981 999999981 999999981 999999981 999999981 410924212 999999981 999999981 959094338 999999981 806122749 225452616 999999981 999999981 999999981 999999981 999999981 999999981 999999981 999999981 999999981 728497588 999999...

output:

66742
66741
66740
66739
66738
66737
66737
66736
66735
66734
66733
66733
66732
66731
66730
66729
66728
66727
66726
66725
66724
66723
66723
66723
66723
66723
66722
66721
66720
66720
66719
66718
66717
66716
66716
66715
66714
66713
66713
66712
66712
66711
66711
66710
66709
66708
66707
66707
66706
66706
...

result:

ok 250001 lines

Test #28:

score: 0
Accepted
time: 3572ms
memory: 64824kb

input:

100000 250000
999983432 999983432 999983432 999983432 999983432 999983432 599939613 999983432 999983432 999983432 32616393 972407866 999983432 631379484 807942580 686883818 999983432 222015091 751344820 999983432 999983432 999983432 999983432 999983432 999983432 999983432 5814454 149875208 999983432...

output:

66678
66677
66676
66675
66674
66674
66673
66672
66671
66670
66669
66668
66668
66667
66666
66666
66666
66666
66665
66665
66664
66664
66663
66662
66661
66660
66660
66660
66660
66660
66660
66660
66660
66659
66658
66658
66657
66657
66657
66656
66655
66654
66653
66653
66652
66651
66651
66650
66649
66648
...

result:

ok 250001 lines

Test #29:

score: 0
Accepted
time: 3761ms
memory: 64672kb

input:

100000 250000
999988304 999988304 999988304 999988304 999988304 234551441 714438885 280102669 999988304 70707593 426860644 999988304 107567124 752699322 170585391 289412001 999988304 999988304 333705407 11569488 999988304 628692358 999988304 999988304 999988304 292308423 845803547 999988304 99998830...

output:

66366
66365
66364
66363
66362
66362
66361
66360
66359
66358
66358
66358
66357
66357
66356
66356
66355
66354
66353
66353
66353
66352
66351
66351
66350
66349
66349
66348
66348
66348
66348
66347
66346
66345
66344
66343
66342
66342
66341
66340
66339
66338
66337
66336
66336
66336
66336
66335
66334
66333
...

result:

ok 250001 lines

Test #30:

score: 0
Accepted
time: 4310ms
memory: 64644kb

input:

100000 250000
664575124 999992401 999992401 999992401 999992401 284065728 999992401 999992401 999992401 999992401 38476082 166909867 697327885 999992401 486301633 999992401 125684772 999992401 114762219 999992401 999992401 999992401 999992401 999992401 326763594 852217607 999992401 372415076 9999924...

output:

66584
66583
66583
66582
66582
66582
66581
66580
66579
66578
66577
66576
66576
66575
66575
66575
66575
66575
66575
66574
66573
66572
66572
66572
66571
66571
66571
66570
66570
66570
66569
66568
66567
66566
66565
66564
66564
66563
66562
66561
66560
66559
66558
66558
66557
66557
66556
66555
66555
66554
...

result:

ok 250001 lines

Test #31:

score: 0
Accepted
time: 4057ms
memory: 64704kb

input:

100000 250000
999999784 778967601 21139690 910446639 999999784 999999784 510563830 999999784 999999784 758557937 555739811 999999784 999999784 283267924 999999784 999999784 999999784 999999784 999999784 771439298 999999784 787673672 290028462 999999784 999999784 999999784 128066029 999999784 9999997...

output:

66529
66529
66528
66527
66526
66525
66524
66524
66523
66522
66522
66522
66521
66520
66519
66519
66519
66518
66517
66516
66516
66516
66515
66515
66514
66513
66512
66512
66511
66510
66509
66508
66507
66507
66506
66505
66504
66503
66502
66502
66502
66501
66500
66500
66500
66499
66498
66498
66497
66496
...

result:

ok 250001 lines

Test #32:

score: 0
Accepted
time: 2835ms
memory: 64704kb

input:

100000 250000
953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813422 953813...

output:

99161
99163
99164
99166
99168
99169
99171
99173
99175
99176
99178
99180
99182
99182
99183
99185
99186
99188
99190
99192
99194
99196
99198
99200
99201
99202
99203
99205
99207
99209
99211
99212
99214
99215
99217
99219
99221
99222
99224
99226
99229
99230
99231
99232
99234
99236
99238
99240
99241
99242
...

result:

ok 250001 lines

Test #33:

score: 0
Accepted
time: 3242ms
memory: 64724kb

input:

100000 250000
976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091974 976091...

output:

99101
99102
99104
99106
99108
99110
99112
99114
99115
99116
99117
99118
99119
99120
99122
99125
99127
99129
99130
99131
99133
99135
99136
99137
99138
99139
99141
99143
99144
99145
99146
99147
99148
99150
99152
99153
99155
99156
99158
99159
99161
99163
99165
99167
99169
99170
99172
99173
99175
99177
...

result:

ok 250001 lines

Test #34:

score: 0
Accepted
time: 3198ms
memory: 64732kb

input:

100000 250000
984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228313 984228...

output:

98982
98984
98985
98987
98988
98991
98992
98994
98996
98998
99000
99001
99003
99005
99006
99008
99010
99012
99014
99016
99018
99020
99022
99024
99026
99028
99030
99032
99034
99036
99038
99039
99041
99042
99044
99046
99048
99050
99051
99052
99053
99055
99057
99059
99061
99063
99065
99068
99069
99071
...

result:

ok 250001 lines

Test #35:

score: 0
Accepted
time: 4125ms
memory: 64660kb

input:

100000 250000
997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296570 997296...

output:

97711
97713
97715
97717
97719
97721
97723
97725
97727
97729
97731
97733
97735
97736
97738
97740
97742
97744
97746
97747
97749
97751
97753
97755
97757
97761
97763
97765
97766
97768
97770
97772
97774
97776
97778
97781
97783
97785
97787
97790
97792
97795
97797
97799
97800
97802
97804
97806
97808
97810
...

result:

ok 250001 lines

Test #36:

score: -100
Time Limit Exceeded

input:

100000 250000
999986079 999986079 999986079 999986079 999986079 999986079 999986079 999986079 999942321 999986079 999942321 999942321 999942321 999942321 999942321 999942321 999942321 999942321 999942321 999942321 999811704 999811704 999811704 999811704 999811704 999811704 999811704 999732963 999732...

output:


result: