QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#392827#7611. Max-Mini_am_noob#AC ✓1676ms19616kbC++145.0kb2024-04-17 21:04:062024-04-17 21:04:07

Judging History

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

  • [2024-04-17 21:04:07]
  • 评测
  • 测评结果:AC
  • 用时:1676ms
  • 内存:19616kb
  • [2024-04-17 21:04:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

using ll=long long;
using pii=pair<int,int>;
#define pb push_back
#define all(a) a.begin(),a.end()
#define sz(a) ((int)a.size())

const int N=1<<19;

template<int(*op)(int,int),int(*e)()>
struct segtree{
    int val[N<<1];
    segtree(){for(int i=0; i<(N<<1); ++i) val[i]=e();}
    void set(int p, int x){
        p+=N;
        val[p]=x;
        for(p>>=1; p; p>>=1) val[p]=op(val[p<<1],val[p<<1|1]);
    }
    int query(int l, int r){
        if(l>r) return e();
        int res=e();
        l+=N,r+=N;
        while(l<r){
            if(l%2) res=op(res,val[l]),l++;
            if(r%2==0) res=op(res,val[r]),r--;
            l>>=1,r>>=1;
        }
        if(l==r) res=op(res,val[l]);
        return res;
    }
};

int n,q,a[N],l[N],r[N];

int op_max(int x, int y){return max(x,y);}
int e_max(){return -1e9;}
int op_min(int x, int y){return min(x,y);}
int e_min(){return 1e9;}

segtree<op_max,e_max> tree_max;
segtree<op_min,e_min> tree_min;

void ahcorz(){
    cin >> n >> q;
    for(int i=0; i<n; ++i) cin >> a[i];
    ll res=0;
    vector<int> stk={-1};
    for(int i=0; i<n; ++i){
        while(stk.back()>=0&&a[i]>a[stk.back()]) stk.pop_back();
        l[i]=stk.back();
        stk.pb(i);
    }
    stk={n};
    for(int i=n-1; i>=0; --i){
        while(stk.back()<n&&a[i]>=a[stk.back()]) stk.pop_back();
        r[i]=stk.back();
        stk.pb(i);
    }
    for(int i=0; i<n; ++i) res+=1ll*a[i]*(i-l[i])*(r[i]-i);
    stk={-1};
    for(int i=0; i<n; ++i){
        while(stk.back()>=0&&a[i]<a[stk.back()]) stk.pop_back();
        l[i]=stk.back();
        stk.pb(i);
    }
    stk={n};
    for(int i=n-1; i>=0; --i){
        while(stk.back()<n&&a[i]<=a[stk.back()]) stk.pop_back();
        r[i]=stk.back();
        stk.pb(i);
    }
    for(int i=0; i<n; ++i) res-=1ll*a[i]*(i-l[i])*(r[i]-i);
    for(int i=0; i<n; ++i) tree_max.set(i,a[i]),tree_min.set(i,a[i]);
    //cout << res << "\n";
    while(q--){
        char c; int p; cin >> c >> p; p--;
        //for(int i=0; i<n; ++i) cout << a[i] << ' ';
        //cout << '\n';
        if(c=='+'){
            int L=p,R=p,L2=p,R2=p;
            if(p>0&&a[p-1]<=a[p]){
                int ok=p,ng=-1;
                while(abs(ok-ng)>1){
                    int mid=ok+ng>>1;
                    if(tree_max.query(mid,p)==a[p]) ok=mid;
                    else ng=mid;
                }
                L=ok;
            }
            else{
                int ok=p,ng=-1;
                while(abs(ok-ng)>1){
                    int mid=ok+ng>>1;
                    if(tree_min.query(mid,p-1)>a[p]) ok=mid;
                    else ng=mid;
                }
                L2=ok;
            }
            if(p+1<n&&a[p+1]<=a[p]){
                int ok=p,ng=n;
                while(abs(ok-ng)>1){
                    int mid=ok+ng>>1;
                    if(tree_max.query(p,mid)==a[p]) ok=mid;
                    else ng=mid;
                }
                R=ok;
            }
            else{
                int ok=p,ng=n;
                while(abs(ok-ng)>1){
                    int mid=ok+ng>>1;
                    if(tree_min.query(p+1,mid)>a[p]) ok=mid;
                    else ng=mid;
                }
                R2=ok;
            }
            //cout << L << ' ' << R << ' ' << L2 << ' ' << R2 << "\n";
            res+=1ll*(p-L+1)*(R-p+1);
            res-=1ll*(p-L2+1)*(R2-p+1);
            a[p]++;
        }
        else{
            int L=p,R=p,L2=p,R2=p;
            if(p>0&&a[p-1]>=a[p]){
                int ok=p,ng=-1;
                while(abs(ok-ng)>1){
                    int mid=ok+ng>>1;
                    if(tree_min.query(mid,p)==a[p]) ok=mid;
                    else ng=mid;
                }
                L=ok;
            }
            else{
                int ok=p,ng=-1;
                while(abs(ok-ng)>1){
                    int mid=ok+ng>>1;
                    if(tree_max.query(mid,p-1)<a[p]) ok=mid;
                    else ng=mid;
                }
                L2=ok;
            }
            if(p+1<n&&a[p+1]>=a[p]){
                int ok=p,ng=n;
                while(abs(ok-ng)>1){
                    int mid=ok+ng>>1;
                    if(tree_min.query(p,mid)==a[p]) ok=mid;
                    else ng=mid;
                }
                R=ok;
            }
            else{
                int ok=p,ng=n;
                while(abs(ok-ng)>1){
                    int mid=ok+ng>>1;
                    if(tree_max.query(p+1,mid)<a[p]) ok=mid;
                    else ng=mid;
                }
                R2=ok;
            }
            //cout << L << ' ' << R << ' ' << L2 << ' ' << R2 << "\n";
            res+=1ll*(p-L+1)*(R-p+1);
            res-=1ll*(p-L2+1)*(R2-p+1);
            a[p]--;
        }
        tree_max.set(p,a[p]),tree_min.set(p,a[p]);
        cout << res << "\n";
    }
}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    int t=1; //cin >> t;
    while(t--) ahcorz();
}

詳細信息

Test #1:

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

input:

3 6
0 0 -1
+ 3
+ 3
- 2
- 2
+ 2
+ 1

output:

0
2
5
8
5
6

result:

ok 6 lines

Test #2:

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

input:

1 1
0
+ 1

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 369ms
memory: 16644kb

input:

1025 500000
-100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -10...

output:

104959999997
104960179065
104960179062
104960199263
104960199266
104960293315
104960472383
104960378334
104960526073
104960517442
104960526681
104960705749
104960798348
104960619280
104960619277
104960619274
104960619271
104960619274
104960440206
104960652725
104960652722
104960652725
104960652722
1...

result:

ok 500000 lines

Test #4:

score: 0
Accepted
time: 1208ms
memory: 17896kb

input:

500000 500000
54181 46637 -2621 18334 55372 -53002 82186 -1463 93261 63053 -79663 98576 -95766 91470 58638 31500 85909 76726 -20694 -5761 48617 34968 4886 55627 -42510 45591 89565 -79895 65387 -64403 -77506 97343 94193 46041 -85383 2673 74798 -54541 43604 -29672 72296 -28317 8037 -65719 -54207 53468...

output:

24998004876352508
24998004876352519
24998004876352517
24998004876356492
24998004876355181
24998004876355182
24998004876355205
24998004876355205
24998004876355210
24998004876355157
24998004876355142
24998004876355146
24998004876353597
24998004876353606
24998004876354550
24998004876354548
249980048763...

result:

ok 500000 lines

Test #5:

score: 0
Accepted
time: 1176ms
memory: 18000kb

input:

500000 500000
-1 -2 1 1 0 -3 0 3 1 0 -2 -1 1 -2 1 3 0 -3 -3 -2 -1 -3 1 -2 -3 0 2 0 -1 0 -2 -1 2 0 -3 2 -1 -3 -2 2 -2 -1 -1 -1 1 -3 0 0 -3 3 -3 0 0 -3 1 0 3 -2 1 1 0 2 1 1 -2 2 -2 -3 1 1 0 -2 -3 -3 0 1 -1 -1 1 1 1 -3 2 -2 3 1 2 3 3 0 -1 -1 -2 1 2 1 -2 -2 3 1 3 2 -1 2 -3 -1 -2 -2 2 -2 3 -1 3 3 3 -3 1 ...

output:

749990346961
749990346971
749990346988
749990346992
749990346993
749990346993
809605564336
871925650829
881066164939
881066164942
881066164934
881066164934
881066164969
881066164972
881066164973
887216105984
887216105969
887216105974
900693012690
902436118847
902436118827
902436118818
902436118929
9...

result:

ok 500000 lines

Test #6:

score: 0
Accepted
time: 1505ms
memory: 18572kb

input:

500000 500000
50000 50000 49999 49998 49998 49997 49997 49997 49996 49995 49995 49995 49992 49992 49991 49990 49990 49990 49989 49989 49989 49988 49987 49987 49986 49986 49986 49986 49985 49985 49985 49984 49984 49984 49984 49983 49983 49983 49982 49982 49982 49981 49980 49979 49979 49979 49979 4997...

output:

6251153789925450
6251153789763576
6251153789541527
6251153790454170
6251153790900554
6251153790827024
6251153790727306
6251153791965831
6251153793320525
6251153794182062
6251153794344648
6251153795092139
6251153794954252
6251153795716866
6251153795803477
6251153796125622
6251153796351459
62511537964...

result:

ok 500000 lines

Test #7:

score: 0
Accepted
time: 1506ms
memory: 18488kb

input:

500000 500000
50001 50000 49998 49999 49997 49998 49997 49997 49995 49995 49996 49996 49996 49995 49995 49994 49993 49994 49994 49994 49993 49993 49991 49993 49989 49990 49989 49988 49987 49988 49986 49985 49985 49987 49985 49985 49981 49982 49982 49982 49983 49981 49980 49980 49980 49980 49979 4997...

output:

6253323343133900
6253323343563847
6253323343418702
6253323342998034
6253323342998030
6253323342998051
6253323342998048
6253323342998049
6253323342885308
6253323341644059
6253323341418715
6253323341658184
6253323344075703
6253323342343989
6253323342369475
6253323341943180
6253323341780542
62533233416...

result:

ok 500000 lines

Test #8:

score: 0
Accepted
time: 1293ms
memory: 18020kb

input:

500000 500000
-5700 -5699 -5700 -5700 -5698 -5699 -5698 -5699 -5700 -5699 -5701 -5700 -5700 -5697 -5699 -5699 -5700 -5699 -5699 -5700 -5698 -5700 -5700 -5700 -5700 -5695 -5699 -5700 -5697 -5699 -5700 -5697 -5699 -5700 -5700 -5699 -5699 -5699 -5699 -5698 -5698 -5698 -5701 -5699 -5699 -5698 -5695 -569...

output:

713179809156264
713179809156215
713179809156210
713179809156208
713179809156193
713179809156196
713179809156143
713179809156146
713179809108795
713179809065887
713179807453886
713179807453863
713179807453865
713179807453862
713179807453941
713179807453941
713179807453928
713179807453923
713179807453...

result:

ok 500000 lines

Test #9:

score: 0
Accepted
time: 711ms
memory: 18032kb

input:

500000 500000
5 3 -1 3 -2 -2 4 3 -5 3 5 -4 0 5 2 3 3 -4 4 -4 3 -3 2 -3 -4 -3 3 -1 -4 1 -4 -5 4 -3 2 1 5 -3 4 0 3 -5 2 2 3 -3 0 0 5 0 4 -4 5 3 -3 4 0 -4 -3 3 3 0 -3 1 -3 3 -5 4 5 -3 4 4 -4 1 1 5 1 -3 5 5 -3 2 -2 1 -5 -2 5 5 1 -3 2 -5 -4 -2 0 5 -3 2 -2 -1 -1 -3 1 5 -1 5 3 5 -1 -1 -3 2 4 -1 1 -3 -3 -3 ...

output:

1249980351918
1249980351663
1249980351615
1249980351588
1249980351589
1249980351478
1310085722571
1310085722532
1310085722515
1310085722507
1310085722546
1310085722547
1310085722658
1310085722571
1370191974458
1370191974447
1370191974420
1370195262616
1370195261697
1370195261432
1310089009545
131008...

result:

ok 500000 lines

Test #10:

score: 0
Accepted
time: 810ms
memory: 17884kb

input:

500000 500000
-9 197 -106 -353 178 722 180 341 729 -714 781 -314 -92 -706 479 -686 -744 626 182 -851 -121 -927 349 -532 346 509 288 -991 788 516 773 532 -576 178 857 -501 404 537 858 676 -410 887 23 -764 -729 -371 -886 -599 127 134 -259 59 77 -293 -46 -733 605 279 -829 -59 -147 180 -504 -484 113 -82...

output:

250046403667257
250046403454956
250046400838453
250046388481310
250079118507169
250099029784939
250104429790746
250108486422971
250111235091744
250111234969434
250171086933451
250171086163036
250171080534967
250167023902742
250167024025052
250211137697815
250220875267276
250280727231293
250220875267...

result:

ok 500000 lines

Test #11:

score: 0
Accepted
time: 919ms
memory: 17948kb

input:

500000 500000
-84462 -88141 66082 -42728 -51534 8492 87024 -51053 -46657 -65482 -84566 25015 75859 17241 -80367 -96705 -48968 -39472 26382 -63638 89126 6784 20239 91981 -50116 -64446 8316 -91840 62002 -76657 6396 20060 65350 85101 -69463 16461 71644 47340 33461 -77765 -45992 -99011 10371 72086 42468...

output:

24997574286813795
24997593578536523
24997583886102441
24997593728194163
24997551354790195
24997519958850867
24997530857361907
24997560658303836
24997592054243164
24997597280670083
24997567479728154
24997563357846415
24997562743054666
24997597589811321
24997596678167068
24997591451740149
249975923633...

result:

ok 500000 lines

Test #12:

score: 0
Accepted
time: 1676ms
memory: 19540kb

input:

500000 500000
23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 23315 2331...

output:

4633301419
9266602838
9481917507
9697232176
5063930757
9697232176
5063930757
430629338
57666499462
68814346015
77988562807
82621864226
82406549557
82674184398
82691573217
90036097739
90018708920
120785400551
126906373306
120785400551
160309186805
169411244860
174309191283
182132073382
185590046403
1...

result:

ok 500000 lines

Test #13:

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

input:

100 100
10 -1 7 10 6 0 -6 1 -2 -10 -3 8 8 6 5 10 5 8 -8 7 -6 6 10 9 -5 -5 -1 -9 -7 0 -6 2 2 6 -6 2 -9 7 1 4 10 1 -1 -7 -7 4 -7 -5 -4 -5 -7 -6 -1 8 -4 10 -2 -7 9 -5 4 6 9 2 8 5 -4 7 2 6 4 -4 -6 7 -1 1 -4 10 -4 4 -1 2 -3 7 -2 -5 4 8 -9 -3 -7 3 3 -8 -4 -6 3 -6 9 -9
+ 11
+ 63
+ 100
+ 1
- 69
+ 95
+ 94
+ ...

output:

87561
87665
87655
87754
87759
87762
87733
87726
87691
87691
87680
87675
89445
89336
90815
90812
90818
90819
90820
90817
90806
90807
90818
90821
90832
90835
90815
90810
90807
90817
90846
90839
90804
90807
90804
90819
90834
90914
90876
90872
90883
91257
91257
91262
91999
92012
92013
92013
92008
92015
...

result:

ok 100 lines

Test #14:

score: 0
Accepted
time: 1343ms
memory: 18576kb

input:

500000 500000
-100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -...

output:

24999949999999997
24999949999999994
24999949999999991
24999993576533458
24999993576533455
24999993576533458
25000056071183135
25000056071183132
25000058304210031
25000058304210028
25000092108652451
25000092108652448
25000101484742747
25000101484742750
25000101484742753
25000085782690830
250000764066...

result:

ok 500000 lines

Test #15:

score: 0
Accepted
time: 1671ms
memory: 19552kb

input:

500000 500000
80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 80001 8000...

output:

42339799843
45383875254
49284061703
60873242339
62630303518
64299196641
68199383090
77787173239
101927884956
100258991833
160104055520
156203869071
160104055520
156203869071
96358805384
94601744205
103369110140
117459019587
118288036090
110636443667
109651005618
115305675131
118284987943
10257786585...

result:

ok 500000 lines

Test #16:

score: 0
Accepted
time: 1374ms
memory: 18416kb

input:

500000 500000
-100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -...

output:

24999949999999997
24999949999999994
24999949999999991
24999949999999988
24999949999999985
24999949999999982
24999949999999979
24999949999999976
24999999949192983
24999999949192986
24999999949192989
24999999949192986
24999999949192989
25000002235015500
25000002235015497
25000002235015500
250000013481...

result:

ok 500000 lines

Test #17:

score: 0
Accepted
time: 327ms
memory: 19544kb

input:

500000 500000
100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000...

output:

499999
999998
1499997
1999996
2499995
2999994
3499993
3999992
4499991
4999990
5499989
5999988
6499987
6999986
7499985
7999984
8499983
8999982
9499981
9999980
10499979
10999978
11499977
11999976
12499975
12999974
13499973
13999972
14499971
14999970
15499969
15999968
16499967
16999966
17499965
1799996...

result:

ok 500000 lines

Test #18:

score: 0
Accepted
time: 320ms
memory: 19616kb

input:

500000 500000
-100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -100000 -10000...

output:

499999
999998
1499997
1999996
2499995
2999994
3499993
3999992
4499991
4999990
5499989
5999988
6499987
6999986
7499985
7999984
8499983
8999982
9499981
9999980
10499979
10999978
11499977
11999976
12499975
12999974
13499973
13999972
14499971
14999970
15499969
15999968
16499967
16999966
17499965
1799996...

result:

ok 500000 lines

Test #19:

score: 0
Accepted
time: 538ms
memory: 18416kb

input:

500000 500000
100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 1...

output:

25000012500249999
25000075000499998
25000137500749997
25000200000999996
25000262501249995
25000325001499994
25000387501749993
25000450001999992
25000512502249991
25000575002499990
25000637502749989
25000700002999988
25000762503249987
25000825003499986
25000887503749985
25000950003999984
250010125042...

result:

ok 500000 lines

Test #20:

score: 0
Accepted
time: 814ms
memory: 19464kb

input:

500000 500000
90318 -75898 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 -12425 ...

output:

292580101461
292580101458
292580101461
292580101458
292580101461
292580101458
292580101461
292580101462
292580101461
292580101462
292580101461
292580101458
292580101461
292580101458
292580101453
292580101446
292580101453
292580101446
292580101453
292580101458
292580101461
292580101458
292580101453
2...

result:

ok 500000 lines

Test #21:

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

input:

100 100
-12 -10 -8 -9 -9 -9 -10 -7 -7 -7 -7 -6 -6 -6 -7 -7 -3 -4 -6 -4 -2 -1 -1 -1 0 0 1 -2 0 2 4 2 5 6 5 6 7 7 7 7 7 7 8 9 9 9 12 8 10 12 9 9 10 8 9 7 7 7 7 7 6 7 4 6 5 4 5 4 4 2 3 1 2 -1 -3 0 -2 0 0 -4 -2 -3 -4 -3 -5 -5 -6 -6 -6 -6 -7 -7 -8 -7 -9 -8 -9 -10 -9 -10
+ 32
- 46
- 72
+ 89
- 99
+ 15
- 30...

output:

62027
62032
62117
62152
62149
62147
62159
62154
62154
61700
61615
61582
61591
61580
61536
61664
61485
61333
61464
61449
61697
61688
61608
59071
59133
59121
58993
58999
58900
58808
59080
59089
59079
59142
59083
59083
59008
59099
59008
58680
58721
58694
58674
58471
58296
58293
58300
58340
58334
58147
...

result:

ok 100 lines

Test #22:

score: 0
Accepted
time: 9ms
memory: 17072kb

input:

300 10000
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37...

output:

10439
0
20487
38976
18489
24788
26515
48108
55219
55458
55039
53960
61735
54624
55631
63846
64457
63612
55397
58477
57866
60681
68896
62656
62811
63585
63430
69589
64910
65065
65224
64822
67084
71503
71248
64825
85668
74399
82070
95789
82070
94759
104976
92287
85127
86911
76694
61899
51955
54519
628...

result:

ok 10000 lines

Test #23:

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

input:

300 10000
-100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -100 100 -1...

output:

8987099
8990634
8993261
9014576
9014573
9037202
9047341
9047338
9069975
9047338
9047335
9069964
9069967
9069964
9092593
9115222
9115219
9092590
9069961
9069958
9047329
9047332
9046019
9046022
9046019
9046022
9046019
9046022
9046025
9046022
9049165
9046956
9041029
9041026
9063655
9041026
9043705
9043...

result:

ok 10000 lines

Test #24:

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

input:

1 500000
56341
+ 1
+ 1
+ 1
+ 1
- 1
- 1
+ 1
- 1
- 1
- 1
+ 1
- 1
+ 1
- 1
- 1
- 1
+ 1
- 1
+ 1
- 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
- 1
- 1
- 1
+ 1
+ 1
+ 1
+ 1
+ 1
- 1
- 1
+ 1
- 1
- 1
+ 1
- 1
+ 1
- 1
- 1
- 1
+ 1
- 1
- 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:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 500000 lines

Test #25:

score: 0
Accepted
time: 70ms
memory: 17816kb

input:

500000 1
87264 -46622 83983 29780 -26107 34378 47137 -46083 49909 -24411 -48502 52566 -98788 -96543 -38478 29848 62915 4353 37968 13624 10437 -24703 -97034 -30965 -31685 -85360 31834 -34540 68700 45597 -84104 -46937 82101 -64326 58652 93388 29079 28646 -5930 4070 20172 -64537 77467 41029 26395 7374 ...

output:

24998054791576670

result:

ok single line: '24998054791576670'

Test #26:

score: 0
Accepted
time: 369ms
memory: 16968kb

input:

1023 500000
-100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -10...

output:

104550599997
104550599994
104550599997
104550599994
104550599991
104550599994
104550599991
104550599994
104550845496
104550599994
104550603056
104550603059
104550603062
104550861841
104551121190
104551119553
104550860774
104550914923
104550810614
104551054801
104551054798
104551054795
104551054792
1...

result:

ok 500000 lines

Test #27:

score: 0
Accepted
time: 372ms
memory: 16760kb

input:

1024 500000
-100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -100000 100000 -10...

output:

104755379423
104755200000
104755199997
104755199994
104755199997
104755199994
104755458867
104755458870
104755199997
104755379420
104755199997
104755335560
104755598173
104755603760
104755603763
104755603760
104755468197
104755462610
104755523809
104755542968
104755542965
104755542962
104755573261
1...

result:

ok 500000 lines

Extra Test:

score: 0
Extra Test Passed