QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#741849#2530. Stock AnalysisNMK#AC ✓1036ms209388kbC++172.7kb2024-11-13 15:21:092024-11-13 15:21:11

Judging History

This is the latest submission verdict.

  • [2024-11-13 15:21:11]
  • Judged
  • Verdict: AC
  • Time: 1036ms
  • Memory: 209388kb
  • [2024-11-13 15:21:09]
  • Submitted

answer

#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>

using namespace std;
#define int long long
using qu = array<int,4>;
using tu = array<int,3>;
const int inf = 1e18;
struct bigseg{
    struct smallseg {
        vector<int> t; int n;
        smallseg() {}
        smallseg(int x){n=x+1;t.assign(2*n+5,-inf);}
        void upd(int p,int v){
            for(p+=n;p;p>>=1) t[p] = max(t[p],v);
        }
        int query(int l,int r){
            int ret = -inf;
            for(l+=n,r+=n+1;l<r;l>>=1,r>>=1){
                if(l&1) ret = max(ret,t[l++]);
                if(r&1) ret = max(ret,t[--r]);
            }
            return ret;
        }
    };
    vector<vector<int>> v;
    vector<smallseg> t; int n;
    bigseg(int x){
        n = x+1; t.resize(2*n+5);
    }
    void build(){
        for(auto &i : v) {
            sort(i.begin(),i.end());
            i.erase(unique(i.begin(),i.end()),i.end());
        }
        for(int i=1;i<=2*n;i++) t[i] = smallseg(n);
    }
    void insert(int p,int x,int y){ // insert(x) = push(a)
        for(p+=n;p;p>>=1) t[p].upd(x,y);
    }
    
    int subquery(int x,int p){
        return t[x].query(p,n);
    }
    int query(int l,int r,int p){
        int ret = -inf;
        for(l+=n,r+=n+1;l<r;l>>=1,r>>=1){
            if(l&1) ret = max(ret,subquery(l++,p));
            if(r&1) ret = max(ret,subquery(--r,p));
        }
        return ret;
    }
};
const int MXN = 2e3+5;
int A[MXN], P[MXN], S[MXN][MXN];
vector<int> my[MXN];
int pos[MXN];
signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int n, q; cin >> n >> q;
    for(int i=1;i<=n;i++) {
        cin >> A[i]; P[i] = P[i-1]+A[i];
    }
    auto cmp = [&](int x,int y){
        return P[x]>P[y];
    };
    bigseg t(n+5);
    vector<tu> sums;
    for(int i=1;i<=n;i++){
        vector<int> v(i);
        iota(v.begin(),v.end(),0);
        sort(v.begin(),v.end(),cmp);
        my[i] = v;
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<i;j++) sums.push_back({P[i]-P[j],i,j});
    }
    sort(sums.begin(),sums.end());
    t.build();
    vector<qu> Q(q);
    for(int i=0;i<q;i++){
        int l,r,u; cin >> l >> r >> u;
        Q[i] = {l,r,u,i};
    }
    sort(Q.begin(),Q.end(),[&](const qu &i, const qu &j){
        return i[2]<j[2];
    });
    vector<int> ans(q);
    int poi = 0;
    for(auto &[l,r,u,id] : Q){
        while(poi<sums.size() && sums[poi][0]<=u){
            int i = sums[poi][1], j = sums[poi][2];
            t.insert(i,j,P[i]-P[j]);
            poi++;
        }
        ans[id] = t.query(l-1,r,l-1);
    }
    for(int i : ans) {
        if(i==-inf) cout << "NONE\n";
        else cout << i << '\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3688kb

input:

1 3
-1000000000
1 1 -1000000001
1 1 -1000000000
1 1 -999999999

output:

NONE
-1000000000
-1000000000

result:

ok 3 lines

Test #2:

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

input:

6 441
-5 2 3 5 -1 4
1 1 -6
1 1 -5
1 1 -4
1 1 -3
1 1 -2
1 1 -1
1 1 0
1 1 1
1 1 2
1 1 3
1 1 4
1 1 5
1 1 6
1 1 7
1 1 8
1 1 9
1 1 10
1 1 11
1 1 12
1 1 13
1 1 14
1 2 -6
1 2 -5
1 2 -4
1 2 -3
1 2 -2
1 2 -1
1 2 0
1 2 1
1 2 2
1 2 3
1 2 4
1 2 5
1 2 6
1 2 7
1 2 8
1 2 9
1 2 10
1 2 11
1 2 12
1 2 13
1 2 14
1 3 -6...

output:

NONE
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
-5
NONE
-5
-5
-3
-3
-3
-3
-3
2
2
2
2
2
2
2
2
2
2
2
2
2
NONE
-5
-5
-3
-3
-3
0
0
2
3
3
5
5
5
5
5
5
5
5
5
5
NONE
-5
-5
-3
-3
-3
0
0
2
3
3
5
5
5
8
8
10
10
10
10
10
NONE
-5
-5
-3
-3
-1
0
0
2
3
4
5
5
7
8
9
10
10
10
10
10
NONE
-5
-5
-3
-3
-1
0
0...

result:

ok 441 lines

Test #3:

score: 0
Accepted
time: 976ms
memory: 209380kb

input:

2000 200000
781891781 -291323734 -872757068 513405392 224560864 -396795366 -719840473 -630648747 -815236042 625829168 -954811885 -137583873 607981668 -244645989 402154398 -280705503 -663669790 740672420 -366335793 -571760808 168048416 -53297271 -23747906 -420146291 156803989 556175782 -578212743 -17...

output:

NONE
6680637806
39973370991
6680637806
12144895607
38045648934
NONE
11880213612
NONE
NONE
NONE
12144895607
NONE
17423670638
NONE
NONE
7770883724
NONE
15094653205
NONE
NONE
NONE
NONE
11880213612
NONE
NONE
NONE
6680637806
39973370991
NONE
NONE
NONE
NONE
25230418671
9235432231
22073412430
22073412430
1...

result:

ok 200000 lines

Test #4:

score: 0
Accepted
time: 975ms
memory: 208980kb

input:

2000 200000
-197817224 -913234737 -642221909 996853921 -114548075 810749714 -583850004 -348314172 -750180415 486961086 740305573 -651462011 704356333 -682979168 581323680 348254084 -812546165 838117708 -187932400 362131790 437427506 91750774 -326510848 279804019 -278503680 952159861 -231198946 -1988...

output:

NONE
12523252725
NONE
NONE
7065542808
NONE
9020534478
12523252725
NONE
NONE
NONE
NONE
4190944747
12741911558
NONE
12523252725
8986188302
NONE
NONE
NONE
NONE
NONE
NONE
NONE
NONE
19131878714
12523252725
12741911558
1993844838
11614443617
NONE
NONE
8316679982
12741911558
NONE
12523252725
NONE
NONE
NONE...

result:

ok 200000 lines

Test #5:

score: 0
Accepted
time: 956ms
memory: 208564kb

input:

2000 200000
-529709686 -453996090 613674566 661766391 244084208 -254717312 841175089 -465585225 830207292 -779619149 -355936068 510464644 207629559 -101183463 600953574 -812564551 -981863685 -594705991 585798658 -185097291 453474571 -523976968 924309870 -528261677 -728003633 458567088 628683727 6347...

output:

2309994343
-7762955026
-5879036165
-13352113062
3339273975
12584370203
589582999
1451562149
8215802172
-18424462310
-16351260370
-689954203
2885038773
-13276029965
6489721435
-1493440532
-6150142359
866722257
3130831981
-18158026906
2827952469
-940707881
5951968040
5776313232
-24829266626
3910908403...

result:

ok 200000 lines

Test #6:

score: 0
Accepted
time: 159ms
memory: 52984kb

input:

994 22785
-241540021 -740641392 -32711899 7536022 764018951 333851593 -336875690 -282469253 -609111433 625535818 542556825 13735433 383380696 -479466598 471939710 841902633 149143113 -958142699 -168353003 -481398260 -833724708 -54628731 945489815 630859312 796274639 209924378 -308372368 -419085683 7...

output:

1426648176
1970146005
-5571502488
-3609940263
-3989859915
-10069133971
-3258205845
-13189314490
-6365461696
-1068211032
1257297640
-2244457632
-5933333235
-6962868855
632418717
273927080
-3029742158
1980487197
2726486811
-730499144
-2010533395
-66675880
-391653512
-4209316804
-4831883408
-2131611263...

result:

ok 22785 lines

Test #7:

score: 0
Accepted
time: 313ms
memory: 88912kb

input:

1283 104162
563934832 429812966 -946916242 458182382 -682512175 -244717959 -207068442 211085266 -358823020 376697778 -524814659 386162498 -621070760 281442392 -501792984 330175961 -654860457 443885501 -761021002 -278363403 -38886256 762000605 770397864 417897743 -283466553 -189607014 -90750633 53912...

output:

46388894178
235129905
12563640805
9827242333
22786141502
33962359001
30415384607
18816162635
8594565577
-595498904
-405232306
20567771346
12646388894
12463900837
24286257963
4611804842
53078599595
14621074384
18100682218
-248115227
448454230
34311683342
14030977779
13416086767
-777809946
17039165765...

result:

ok 104162 lines

Test #8:

score: 0
Accepted
time: 1035ms
memory: 209244kb

input:

2000 200000
-429624276 -118369488 -430702110 237972537 689220289 311474009 268913498 51943905 572586717 -969863260 -256661891 481566516 -742382433 715404076 889211950 -322002311 522758974 -524428665 816504590 993962822 416045097 -14221792 409395576 592353068 691493783 -256780785 -140683706 744898840...

output:

2704664092
-10822555109
1966718513
8217392803
-8831090276
5604296467
3523024414
-4122893960
1843245266
-5200512987
-2956754491
5122318979
-4882693420
3311804750
-129682839
7252730548
-3670397852
-1855238013
-2068629250
-13554583961
14081700765
-11517100287
-653302127
-1292176224
8271111894
914451778...

result:

ok 200000 lines

Test #9:

score: 0
Accepted
time: 992ms
memory: 208392kb

input:

2000 200000
24096348 -63311351 53145456 -814237328 -87966825 639041688 85775630 27260053 -885026165 -636662404 240182503 559130421 179841499 -893440877 624395629 -316154633 -577548631 868021843 451974286 684451932 -96980430 226369727 -863905867 144090914 -118335559 596866357 568377754 -662496512 -71...

output:

-3450033886
2354624784
-2479005887
-10287578543
5194964898
3890058904
-17450610457
-19397002560
-12908899745
-13285425252
-129067737
-4973627269
-42507184
-136029197
-9274317018
-18332430332
-1316673779
-2600152889
-19804093833
-16662217999
-7477509120
-29828386501
-9103341893
-10935182542
825568748...

result:

ok 200000 lines

Test #10:

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

input:

5 3
1 -2 -3 5 4
1 3 -2
1 5 8
1 5 3

output:

-2
6
2

result:

ok 3 lines

Test #11:

score: 0
Accepted
time: 917ms
memory: 208244kb

input:

2000 200000
-564025973 458009241 -499985240 466343074 11691279 -623401916 -14765445 -739287313 163690668 118599416 -647358175 -518953191 186261172 946950289 121932118 -617513355 55382740 -111121560 -7211395 -976475621 951095691 -22492028 -509262107 -640691068 948510318 377268471 987508333 339170394 ...

output:

-1733754642
-6408230945
275339206
-7961113595
18870655836
-5306194476
960498600
-317581842
9745531420
-5563198702
7991061040
10517854883
7297311727
-7984725569
13747143753
-4282834366
-6723662144
-35117470109
-6229993933
-3084237037
-12914028591
1527822391
-3787513818
-8943227984
-8986236964
7375019...

result:

ok 200000 lines

Test #12:

score: 0
Accepted
time: 940ms
memory: 208412kb

input:

2000 200000
-645941494 -843250615 301155028 -927808768 54357912 -170778140 -66706512 484569729 -145098432 -595756669 355322071 -845965019 299020727 666303577 42155838 -956957195 760062210 24062310 923323624 994094541 92401127 75006083 623275917 438520146 613653867 63993206 61867181 180490098 9700664...

output:

NONE
23484500221
23484500221
23484500221
23484500221
23484500221
NONE
NONE
NONE
23484500221
23484500221
NONE
23484500221
NONE
23484500221
NONE
23484500221
23484500221
NONE
23484500221
NONE
23484500221
NONE
NONE
NONE
NONE
23484500221
NONE
NONE
NONE
NONE
NONE
NONE
NONE
23484500221
23484500221
23484500...

result:

ok 200000 lines

Test #13:

score: 0
Accepted
time: 912ms
memory: 207712kb

input:

2000 200000
-6855963 -146064790 826344916 -273578024 7620989 30139329 507345743 4306512 790488749 -231358597 -193878921 613392894 438624485 -657804724 848933732 -485006364 -256335330 33727325 271275923 -615439672 -434728510 -473434638 -464019367 -410819706 187707163 41480928 -689175923 -880307418 -5...

output:

20222360484
NONE
NONE
NONE
20222360484
20222360484
NONE
NONE
20222360484
NONE
20222360484
NONE
20222360484
NONE
20222360484
20222360484
20222360484
20222360484
20222360484
20222360484
20222360484
NONE
20222360484
20222360484
20222360484
20222360484
NONE
20222360484
NONE
20222360484
20222360484
NONE
...

result:

ok 200000 lines

Test #14:

score: 0
Accepted
time: 481ms
memory: 124628kb

input:

1527 120762
946072584 -670128909 157495542 -143395338 222886896 709546593 801846726 -292508230 174159539 865964272 -169947428 -533913879 -135693663 528019489 250298779 233351017 171463706 -743329169 -993429689 542324396 795606496 807249893 430097520 172405252 -391610321 -556355255 -636568208 -656987...

output:

-23731836492
1613334108
-12359784555
-4567411702
-18388072588
-22384371047
-9447406124
-6861191990
-22870791610
-5786054748
-22384799775
-5542090050
-9443155959
-17601994681
-19460907108
-7845331483
-20085161508
-9165664428
-8134895215
2345747784
-5800911612
-1438311473
-12156419846
-19915053542
-16...

result:

ok 120762 lines

Test #15:

score: 0
Accepted
time: 243ms
memory: 80996kb

input:

1236 24291
-584960076 267912774 -974458236 306499090 813573721 -642915493 -346054611 -993913294 -421716533 178715655 -277177115 -812724917 -695285250 -524909589 422838801 705824391 -601689103 918493029 -366438655 844797713 233758935 360996851 206183581 542632703 347597905 769359750 -552599939 -21401...

output:

-32854160869
7518893140
-16572513843
-14400401550
-18763206767
-26726306607
1511574519
-24938272121
-4700043009
-38717857983
-7376883190
3758978609
-34879017091
-31665666791
-33792011084
1907611528
-5395111376
-33305393861
-2783511973
9812891956
-17287778313
-10136785608
-3762681836
-16491466736
-33...

result:

ok 24291 lines

Test #16:

score: 0
Accepted
time: 987ms
memory: 208604kb

input:

2000 200000
-535652501 -425415492 961515947 955361679 503835834 -479498594 866214036 655757936 708221175 915983216 852495660 84213119 559345803 296378566 -177141328 -505467190 817635322 -61029811 625084878 -476486889 -78453845 884441662 -766854092 880740240 -326352330 387739918 -223712244 -662814147...

output:

7538654876
11705860510
5036702500
7002213349
-6864042551
3820773180
6493142626
-1647182428
16476147798
7604044401
-2729929278
11596633250
-4141449099
-1082631201
17996014271
10490235899
16211401492
-958430651
9142868420
14714915805
6656370013
12490045572
13959158311
12784840801
10090958007
-11704081...

result:

ok 200000 lines

Test #17:

score: 0
Accepted
time: 950ms
memory: 208128kb

input:

2000 200000
-42457403 810587050 -887092688 -792470493 171084878 -632267420 448224935 -910194023 -757679749 752675962 962576595 881595977 -644992036 -352375906 -951158410 261449559 -107733773 662229727 -340175615 -713006941 683992921 198317066 894738691 -12591163 -837724764 163557750 -992386037 22938...

output:

21886781440
11684530240
5520225528
20487394676
28210695991
13376763978
-2834116111
20460561033
18709178515
11759276889
18993163022
4102521410
16880036338
32863634857
-1708305081
11904300861
42847996
17683222834
12544451868
16953581495
18768904621
32021383939
30007157181
11512291731
22010269565
22515...

result:

ok 200000 lines

Test #18:

score: 0
Accepted
time: 965ms
memory: 208192kb

input:

2000 200000
-394952701 -528621185 -697063269 254888546 583923791 245772025 739112451 -503557711 945003472 -667289948 853415248 -993645940 531444098 384671612 -229520559 -210182724 -973870433 -851612284 -791359430 828864110 805578268 239690873 -792738563 -203191637 -180469029 649948840 263942546 8104...

output:

1261106000
-17364930084
954665850
10684468397
-12528121405
12166272840
1137057778
-7393303040
-7514625642
-8483359008
-4613982072
-727158959
-13311976156
6950657837
-10854755113
7980760664
8474149443
-694549171
7238384854
137188917
-932768916
2804377008
-6860828674
6031408691
-15168978447
1238316309...

result:

ok 200000 lines

Test #19:

score: 0
Accepted
time: 924ms
memory: 209388kb

input:

2000 200000
-416157954 -814613323 985910155 -188190047 -201509356 -316808248 -152411444 -201145050 169684807 243415545 265768034 -645799418 176302105 641471635 682774085 134864664 621407228 -602119848 557087381 -334222289 -391251205 681122634 -795420153 -888937454 929243264 668084476 -748030105 -563...

output:

-9619444914
-28684120657
-22502887209
-35800841743
5789987676
9424630638
-15412987195
-14370644913
-23012577349
-3363287830
-26222218993
228628899
-8158855272
-19347939201
-15710058931
8351153
-35386666470
-459641992
3934179468
-10430873271
-9487264371
-23432985041
-28471884264
-6940524992
-28308900...

result:

ok 200000 lines

Test #20:

score: 0
Accepted
time: 979ms
memory: 207840kb

input:

2000 200000
-768 955 772 948 -706 708 713 -574 -622 -683 -639 937 950 -159 249 241 729 85 46 125 -274 -272 689 21 -567 -300 -294 391 872 -686 794 468 133 53 -169 -134 615 -591 -529 153 522 394 853 -406 394 -108 981 -58 254 -912 207 38 -668 738 -557 104 439 -150 805 -474 -859 242 951 -142 622 -598 67...

output:

35450
24614
NONE
3098
NONE
4756
NONE
NONE
NONE
NONE
10676
NONE
NONE
NONE
NONE
35450
21591
NONE
2919
26816
5864
24614
8887
NONE
NONE
NONE
1913
9264
NONE
21687
11035
32858
NONE
NONE
NONE
30444
30918
8083
NONE
NONE
13791
18047
NONE
NONE
NONE
NONE
NONE
14827
36738
NONE
7154
NONE
28907
4729
1141
32201
24...

result:

ok 200000 lines

Test #21:

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

input:

6 4
3 8 -3 2 5 2
1 6 17
1 6 16
2 5 4
2 5 -4

output:

17
15
4
NONE

result:

ok 4 lines

Test #22:

score: 0
Accepted
time: 1011ms
memory: 208436kb

input:

2000 200000
-284 -4 -709 -688 -159 275 -862 -266 26 -289 -231 322 -242 -585 -14 572 997 -573 738 45 989 -85 519 -98 -814 140 -223 537 38 785 -595 -30 914 178 529 -713 52 -295 -24 793 678 819 -485 -844 -998 531 -140 479 871 380 -5 99 -580 619 460 708 -232 -847 143 482 326 451 450 -945 -46 1 -619 -382...

output:

23606
NONE
23606
-465
23606
23606
15834
NONE
19351
NONE
14793
NONE
11562
19841
NONE
11230
NONE
23606
NONE
882
NONE
11709
16111
15612
19841
6270
19841
18990
16111
NONE
NONE
14735
18348
918
23081
7967
13705
15288
23606
NONE
16111
2616
18010
16111
5468
NONE
10246
NONE
NONE
NONE
16111
11709
19841
11709
...

result:

ok 200000 lines

Test #23:

score: 0
Accepted
time: 995ms
memory: 208664kb

input:

2000 200000
840 393 86 -244 -899 -866 -618 -898 280 -907 -29 989 70 -998 -835 -346 -324 237 397 -949 376 -36 -819 402 -172 -480 -600 221 647 179 433 -821 -445 383 -903 699 -384 -705 658 -22 583 838 -8 860 -186 -4 -259 527 -173 -695 742 703 -685 939 -493 -6 -890 -108 -505 -551 -513 -993 -952 -708 891...

output:

26001
3477
-6221
-380
8183
3506
10427
16956
-2543
2667
16129
3743
28181
-2291
32570
10938
9013
5986
2716
1213
-1939
7690
4825
4953
-278
2244
116
12729
28157
17856
-1443
2208
1792
3062
32641
7202
13109
-1505
6481
12876
14820
25697
-5533
1628
506
4034
25316
33090
9511
2481
35998
9825
-515
573
2361
116...

result:

ok 200000 lines

Test #24:

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

input:

339 173175
176 -230 21 -280 -478 -341 222 -126 -183 -915 917 -926 656 -991 -420 -824 520 623 -657 -475 127 -262 262 188 915 737 18 823 -687 -229 919 921 67 -402 -340 6 272 -688 725 812 88 364 442 -583 -507 -394 -261 -429 839 -936 -177 -282 787 -151 435 -486 62 -463 325 -774 735 -393 915 718 13 -291 ...

output:

2937
8391
-289
-2505
10664
-1862
943
4197
382
2221
-194
-1033
-3171
7053
-5561
-1962
3278
2400
6589
-1482
1761
-1338
-107
-4160
7093
-5398
-3213
-557
1707
3440
-6541
-1749
-322
12776
-640
2660
-1132
-1260
-492
-8680
-6021
1552
417
-273
2818
-1796
1865
-6253
-6410
1439
-3310
2231
213
-3966
678
-2814
...

result:

ok 173175 lines

Test #25:

score: 0
Accepted
time: 989ms
memory: 208916kb

input:

2000 200000
-301 -872 -394 75 589 -772 -897 640 315 -150 -120 -217 533 -577 704 -214 -907 338 823 -585 73 770 35 741 73 52 -230 678 65 165 -32 -725 957 284 920 -904 44 -468 -79 53 -114 317 273 -843 33 -797 377 542 657 -608 -321 -992 489 848 -45 162 224 992 425 -842 172 96 -673 -188 -707 -875 91 -721...

output:

-5604
-3662
1663
-679
4415
2095
-1829
3555
-3267
-1469
1591
5469
739
1819
13383
-1050
933
3565
1640
4782
3638
-889
-1467
2704
2437
716
-631
-10432
4855
3650
8939
-3795
-2168
5432
1670
5522
-1758
-11760
6954
-406
-1474
6379
-1650
12175
1340
5747
1330
-4076
-9471
289
2801
-1748
1581
3002
-2284
7957
-1...

result:

ok 200000 lines

Test #26:

score: 0
Accepted
time: 1036ms
memory: 209376kb

input:

2000 200000
-575 963 -958 536 -154 -302 370 -861 277 -181 651 -315 -775 871 51 484 -580 -922 -786 886 -263 419 619 306 662 -752 -209 -435 -373 -589 494 -159 43 -88 25 -673 -256 381 -132 857 -820 663 604 -366 103 803 345 19 -170 325 679 557 854 -279 292 825 644 848 -236 593 986 -900 -797 -571 658 721...

output:

-1453
72
-3263
1762
3486
5637
9024
-1598
-4620
2095
-3031
-7416
-514
-4747
586
-18407
-9963
-1116
4564
3674
-272
-17306
-4090
-3708
2631
-7390
476
-3429
2342
-2267
-62
6832
2902
-5671
-825
3381
780
-913
-12964
1909
5823
-2812
-8605
1073
3017
3292
-758
-2086
3157
8068
-12754
1857
-7946
-3518
553
-200...

result:

ok 200000 lines

Test #27:

score: 0
Accepted
time: 319ms
memory: 92932kb

input:

1335 37289
-825 -381 -541 -802 -489 -815 628 373 -879 -28 202 -899 988 960 891 0 -883 480 -475 -717 -446 880 -241 289 -170 396 199 -807 -794 311 847 474 -421 -678 -579 481 524 -671 -66 295 -665 -854 307 687 -979 -767 -177 437 -683 -225 142 936 27 167 -865 600 -809 -371 -196 -413 454 551 839 336 461 ...

output:

-12480
-9525
-22305
-3403
840
-1595
-5146
-18533
-2208
-19529
682
1953
2791
-10193
-11057
1095
-5609
5866
-5232
1307
-2924
-9174
-5937
-6124
-9122
-4378
119
9266
-276
2630
5559
-2255
-12714
-17722
-5462
-4877
-2936
27
-5664
1551
-4739
-24526
-138
885
-231
-9966
4390
3256
-4060
-16828
-1308
9257
1101...

result:

ok 37289 lines

Test #28:

score: 0
Accepted
time: 1019ms
memory: 208972kb

input:

2000 200000
100 -51 708 865 -165 -193 632 641 95 622 330 -747 -929 -897 872 -523 -702 436 -188 742 578 -129 71 127 15 -981 479 -118 9 904 147 457 -68 -83 -107 770 -974 143 53 11 834 -16 -138 -22 526 -532 451 -29 -386 -170 951 655 823 963 -261 -179 437 520 -506 -587 201 -231 59 -964 -21 154 -406 33 -...

output:

-8722
7152
-3941
-13572
1629
29559
9238
-2031
5956
17368
2958
-18517
5574
11834
-13295
1048
1791
5598
1430
-339
-3616
9940
-3047
-836
-4240
2705
-3582
-9492
1748
-2646
-22
1473
-1005
-90
-9203
15855
-10470
28583
10890
18505
-11960
2058
-10614
5580
6347
-1370
4514
12130
-7465
3910
-1970
350
792
9241
...

result:

ok 200000 lines