QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#482248#785. Historical Maximum Valuelgswdn100 ✓501ms53384kbC++142.9kb2024-07-17 18:34:332024-07-17 18:34:33

Judging History

This is the latest submission verdict.

  • [2024-07-17 18:34:33]
  • Judged
  • Verdict: 100
  • Time: 501ms
  • Memory: 53384kb
  • [2024-07-17 18:34:33]
  • Submitted

answer

//Shirasu Azusa 2024.7
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}

#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;  
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
  int x=0,w=1; char c=getchar();
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();} 
  return x*w;
}

const int N=5e5+5;
int n,m,a[N];

#define ls (p<<1)
#define rs (p<<1|1)
int f[N<<2];
struct node {int s,h;} tag[N<<2],s[N<<2];
node operator * (node x,node y) {return (node){x.s+y.s,max(x.h,x.s+y.h)};}
node operator + (node x,node y) {return (node){max(x.s,y.s),max(x.h,y.h)};}
void add(int p,node z) {s[p]=s[p]*z, tag[p]=tag[p]*z;}
void psd(int p) {add(ls,tag[p]),add(rs,tag[p]),tag[p]=(node){0,0};}
void psu(int p) {s[p]=s[ls]+s[rs], f[p]=f[ls]&&f[rs]&&(s[ls].s==s[rs].s);}
void add(int p,int l,int r,int x,int y,int z) {
  if(l==x&&r==y) {add(p,(node){z,max(0ll,z)}); return;} int mid=l+r>>1; psd(p);
  if(y<=mid) add(ls,l,mid,x,y,z); else if(x>mid) add(rs,mid+1,r,x,y,z);
  else add(ls,l,mid,x,mid,z), add(rs,mid+1,r,mid+1,y,z); psu(p);
}
void cov(int p,int l,int r,int x,int y,int z) {
  if(l==x&&r==y&&f[p]) {add(p,(node){z-s[p].s,max(0ll,z-s[p].s)}); return;} int mid=l+r>>1; psd(p);
  if(y<=mid) cov(ls,l,mid,x,y,z); else if(x>mid) cov(rs,mid+1,r,x,y,z);
  else cov(ls,l,mid,x,mid,z), cov(rs,mid+1,r,mid+1,y,z); psu(p);
}
node qry(int p,int l,int r,int x,int y) {
  if(l==x&&r==y) return s[p]; int mid=l+r>>1; psd(p);
  if(y<=mid) return qry(ls,l,mid,x,y);
  else if(x>mid) return qry(rs,mid+1,r,x,y);
  else return qry(ls,l,mid,x,mid)+qry(rs,mid+1,r,mid+1,y);
}
void build(int p,int l,int r) {
  if(l==r) {s[p].s=s[p].h=a[l]; f[p]=1; return;} int mid=l+r>>1;
  build(ls,l,mid), build(rs,mid+1,r); psu(p);
}

signed main() {
  n=read(), m=read();
  rep(i,1,n) a[i]=read();
  build(1,1,n);
  rep(i,1,m) {
    int op=read(), l=read(), r=read();
    if(op==1) add(1,1,n,l,r,read());
    else if(op==2) cov(1,1,n,l,r,read());
    else {
      auto [s,h]=qry(1,1,n,l,r);
      if(op==3) printf("%lld\n",s);
      else printf("%lld\n",h);
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 10164kb

input:

3099 3049
-32568688 443807346 233942259 848417941 680392130 423248798 -421766523 -644713801 827124811 -189291555 -872080262 334039268 -966090531 130399216 -420600424 -632248754 -491536425 -93519876 811153156 -503770171 -759881105 -479393911 530366533 638696148 524079932 -533729925 324347769 81510371...

output:

996669020
999989520
1875071105
2063161103
996669020
2152642030
2584601570
2568935396
2439361055
652576203
1604547609
1645247784
373571540
2439361055
1104181537
2209997739
2608538124
2595413074
2350995148
2209997739
1109782942
2608538124
1109782942
1393883738
1393883738
2439361055
2439361055
26085381...

result:

ok 1536 lines

Test #2:

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

input:

349 34
-502595675 -950440943 909151160 -716190554 -415542665 -220995490 275848171 747791962 -657789939 663064713 597426880 -788767096 490705687 -876674034 -528575136 -675837766 875344246 839376899 560970524 726570631 889099520 -807129735 -893402523 399891183 -714124062 51330217 998704312 -955598874 ...

output:

975284527
967551705
966053196
889099520
975284527
923165719
63609087
63609087
1847840252
1144223951
1791042632
1558930394
1163500052
959148225
967551705
975284527
1742109203
606236276

result:

ok 18 lines

Test #3:

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

input:

4371 2525
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000...

output:

625167193551

result:

ok single line: '625167193551'

Test #4:

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

input:

5000 5000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000...

output:

1231166031459

result:

ok single line: '1231166031459'

Test #5:

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

input:

4488 4102
980316884 919162589 -658943037 -553353857 -14454933 -587470785 401236631 -652648915 152611806 713777111 -95398327 487045678 241102910 108624245 177714195 -225825314 -73986457 352652536 -546661139 405525506 -190081891 322993307 489517398 49892112 405910356 685900952 557317127 -49288131 -730...

output:

986726658
986921970
995625536
995625536
996795161
996087452
936366552
-28837456
999179710
996087452
999179710
987010932
999179710
996795161
995625536
995625536
987010932
988472582
303364791
996087452
987010932
996087452
946194689
661686964
486800377
661686964
1079105555
-97369900
511502302
-97369900...

result:

ok 2021 lines

Test #6:

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

input:

598 4834
-322822848 767610244 133869325 588710072 -47421617 -855543855 -708901767 -513083204 -643075359 -943110530 -164139640 -529287749 -775983439 -431233078 -758056065 -90947026 -907891552 -282358379 914395801 -196772280 629855053 906127219 -352447844 777805026 -689749867 716818873 -895982131 1171...

output:

2014210343
-445553513
2014210343
2014210343
1043377093
2014210343
2014210343
-257572467
2014210343
1881680429
1133365811
2014210343
3551183032
4206573992
2067321096
-612450205
2712879696
48250899
2794847738
1812785197
4206573992
4206573992
-728501872
2745792896
-728501872
-728501872
2794847738
42040...

result:

ok 2363 lines

Test #7:

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

input:

3913 2959
715698916 583562129 -412996927 -103704187 -604838995 973875426 399038312 -79352191 508339378 539302122 -214163899 -263415123 -44119352 380975469 516817074 -382620820 121697694 609774532 -854421502 942423113 577105562 -806590423 160689155 -38841426 623607889 337529391 864465524 -254289734 8...

output:

999494025
990223493
999494025
999494025
999293615
998919411
998919411
999494025
998919411
998919411
-185787937
999494025
998919411
999293615
998919411
-185787937
998919411
778558535
836707676
836707676
836707676
1503746506
1503746506
1757688522
2311376930
2311376930
945471231
2311376930
2311376930
2...

result:

ok 1479 lines

Test #8:

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

input:

1699 4091
900883562 218680703 441571479 -906899315 -616453422 380268566 484406283 487947010 274726237 547543239 103391541 -236844414 586651214 972374216 -428185758 405442926 -877660843 808168870 280764635 347118478 318030859 -673815467 832027879 -445988601 -477628135 963175448 286031873 148852511 -8...

output:

993682390
945357927
998597401
997968652
997968652
908821582
986984467
963175448
986984467
346761548
627195146
979661603
993682390
1563368272
1563368272
1563368272
395042978
346761548
1499951264
998597401
998597401
1475310030
993682390
998597401
997968652
990475543
998597401
1563368272
997968652
9904...

result:

ok 2078 lines

Test #9:

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

input:

925 2519
718574612 -69384283 147898428 983134693 138609470 -490632197 -576612110 -413177415 -85562172 -587045969 679948189 -221858988 -168347597 195756317 482469854 -306982254 -439993870 807224505 425801608 -670344638 -569987498 -885634333 751432857 419925500 49239067 -708998203 -949940635 -90280447...

output:

1671292523
1693199034
1813094547
1671292523
-408140778
1693199034
1706288338
1813094547
1813094547
1762137078
443128538
488499072
1684048708
488499072
1311262498
1684048708
488499072
1813094547
1785238794
1684048708
1684048708
1693199034
193465841
193465841
1813094547
1128909357
1813094547
181309454...

result:

ok 1281 lines

Test #10:

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

input:

539 3623
888638906 -615070257 982737095 909937761 -572043026 -304280625 69805014 53139164 -457183199 738944038 -651552238 264708135 660201744 -764815813 913990840 -517397390 -821571422 827676551 -307746502 -417574116 -237830236 -290975057 -734775696 -593034274 -880393723 -447015391 765836598 -818050...

output:

959671561
991186336
991186336
991186336
956478948
988994070
980824059
-353952701
1306830373
1342242301
1306830373
1342242301
1326487956
1342242301
980824059
988994070
925950656
481992377
988994070
-609085851
-609085851
1326487956
1326487956
-270708360
-101416782
982803079
1342242301
1299618340
10418...

result:

ok 1831 lines

Test #11:

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

input:

2617 3363
301949330 -742096696 681957800 919909886 -203133185 197025634 -852861193 508834562 188696493 887144632 163131005 -72113815 -119196571 -241587721 -602479555 -571079978 -486636154 -699196675 -82859709 431995917 57476260 661385085 62719915 809084437 667980776 370670828 -897685263 683270892 89...

output:

1682262814
1077068982
991056621
984910926
1763675740
677394071
1763675740
1787698265
1787698265
1787698265
977858866
958808256
1156272592
1336506725
1336506725
193809913
1787698265
294099043
1644764861
1787698265
1237506803
1787698265
1237506803
1787698265
-1722037330
1763675740
963409504
893163921
...

result:

ok 1695 lines

Test #12:

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

input:

931 2170
-298512826 -459518528 894741579 74502945 488589255 -975161020 596813424 853122273 -969029875 -907346602 -618706333 310603675 568709549 707165922 -134136269 628422301 -188641429 204832323 674012633 193111506 -242332968 -770268735 489989384 474987600 441482248 -742764783 -28957691 925929528 7...

output:

990615591
839135897
996667328
997369381
997369381
997369381
-165813648
879103534
981678509
950079696
670422832
1420037553
670422832
856678070
670422832
994526798
824615085
1117487224
985315118
1032682764
-1764410991
1386884264
1489478973
1247827426
1978022233
1978022233
1978022233
1978022233
1247827...

result:

ok 1088 lines

Test #13:

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

input:

3754 1296
-715748722 53059678 119467375 -836653010 -188755150 -590540706 -372477246 243046793 375819622 -952827276 -650035381 248427611 193812468 281066279 80875554 572496455 259169877 -913610259 902833121 976660472 510862508 838104659 313678804 648386380 -339785164 -81851212 -572077002 359204993 23...

output:

999199095
994247972
995143414
998005724
999199095
442583339
2509209037
2509209037
2509209037
2508712901
2509209037
2509209037
2503333471
2042887382
2503333471
1349519623
248790370
248790370
248790370
2508712901
2508712901
2508712901
1435094418
471954501
2503333471
2503333471
141696484
2503333471
250...

result:

ok 645 lines

Test #14:

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

input:

243 1312
-873443811 -846034244 -467427630 229578360 -76124762 586964438 453858445 -797893612 -824436437 697097309 -423472287 -265767473 404992894 -189784634 -400698559 520645673 240838184 -872166052 -129357175 866759313 208117774 -775509711 -105311020 -842335407 -965319812 105110219 633581651 717006...

output:

967752784
1914222793
1936612462
453410063
1914222793
1936612462
1914222793
1936612462
1936612462
967752784
1936612462
967752784
1393352392
2479265081
816671326
2479265081
2479265081
913477061
29190471
2479265081
-452490553
678530640
866759313
678530640
846841576
1914222793
2479265081
437381686
11691...

result:

ok 646 lines

Test #15:

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

input:

3489 1093
-625019900 537437418 20962697 757975121 722972552 -144663307 -851034104 598976748 943472225 326387973 438545535 697172697 -123517592 -510142513 960360762 572003782 -87478281 -191640787 306399947 -501318018 -140109600 882424058 -920378189 -265237688 295026007 -674327933 807312379 839442447 ...

output:

1201390154
998579597
995789359
990712174
991646617
-980393073
1467971643
1956041092
1160844983
1202862078
391723096
391723096
391723096
1467971643
1758601837
1956041092
1463286341
982131245
1956041092
-114505432
-114505432
1956041092
1956041092
1173242570
870336660
1758601837
1173242570
1758601837
1...

result:

ok 567 lines

Test #16:

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

input:

2862 3220
-940779395 595988466 -993313945 -362301763 -35048262 -804775439 111357243 400257836 -730750398 -765331424 -541540787 289928094 -136049627 -539863156 -461436301 -405691307 -505256378 -975211888 -821655123 -239613957 625135422 42141436 -990386533 -437780263 -640264812 -121758580 -979309415 2...

output:

999781639
999781639
986188771
894380828
1469385859
999781639
1469385859
997301098
1469385859
1134621819
1134621819
1469385859
-402057633
999092946
1469385859
18018529
-362671528
18018529
809989387
18018529
1469385859
986188771
1134621819
-235232081
986188771
1469385859
1178783690
66359145
376344374
...

result:

ok 1631 lines

Test #17:

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

input:

1981 3656
-849876761 -601010228 -503042438 805835670 -552923288 -105089276 -134599321 -903391348 -565649918 -109496173 694474119 -436951458 634573871 640001795 -342193058 -493412650 -669089546 -32833807 617973178 -141161656 835251529 -742774322 873637151 -857041329 514189869 -611379877 -844703686 42...

output:

999813122
990752390
512939028
1367839549
1455559523
1455559523
1455559523
308929160
932492321
936631897
931264330
1443056538
931264330
1443056538
136602227
1124288551
730111453
-390690817
136602227
136602227
1115712335
996335996
1455559523
996437674
1455559523
1163791239
1163791239
1163791239
116379...

result:

ok 1803 lines

Test #18:

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

input:

4032 903
89588613 -999874443 -219363971 831895552 860835624 63373646 388194677 -477713488 -682006129 -240763403 910073110 167951972 -111192707 -310048239 811723263 -417176091 90324260 755901674 471329249 614887302 284402032 885158174 -668413864 895253906 -186467103 498658958 131897748 310520768 1096...

output:

1626469566
998942745
1626469566
997602922
1626469566
-365708938
-365708938
1626469566
988694827
-131991208
-131991208
967426580
1708837014
1733332467
967426580
-131991208
1753369617
967426580
-131991208
-131991208
-131991208
-131991208
1733332467
-131991208
1626469566
-1293976968
1626469566
16264695...

result:

ok 477 lines

Test #19:

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

input:

240 978
975976078 26552347 632856932 698620237 -480456844 388262514 -111666086 910805734 -359876560 -724791414 331583395 228821650 10994060 807124891 509247008 -20374729 -378519356 -947115177 273138675 -495187775 -113446450 -634415353 -511257315 -495570152 25817482 -772588677 977585630 607756595 -37...

output:

889417598
977585630
956030476
277188569
889417598
965121175
977585630
889417598
879115223
591363529
591363529
956030476
670793457
591363529
1198780573
889417598
2192578149
-687596149
2192578149
879115223
1826916554
2554280785
1465213918
744921065
-65587961
1016407528
230769611
2554280785
1743771759
...

result:

ok 480 lines

Test #20:

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

input:

1174 1390
350690052 -973360642 -890640006 792620487 449012519 2474186 233113683 772062899 193361108 864584652 552814481 -858838836 -804542670 -158953914 -700122318 540092879 5172647 -154087283 -521913144 297370863 622669573 -629280444 -280781491 -798485466 108590725 -735838864 -356536038 -896846213 ...

output:

1368693265
1047921904
1452425370
1695661225
1305361394
2287845767
1280278783
998679179
989421623
946200882
904784758
1278537805
2287845767
1593429092
1716720132
904784758
1637590414
-113195851
2287845767
-1425766853
2287845767
-1669606020
223864550
998308460
249471277
2020066795
1687395294
168739529...

result:

ok 661 lines

Test #21:

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

input:

3873 4349
292599285 -790719680 -944967522 -233857318 -602552345 -909689709 926819125 400966107 -165140039 -710056451 482437666 949344714 936213980 -955907831 -558621384 464943684 139731438 562407157 -262744639 86747606 487135280 109004865 -473556435 -619012670 502105414 427320571 943996527 306363671...

output:

998166508
995192948
-467246512
1023879182
937564255
998166508
998549278
1023879182
1016008024
220067267
1627932144
1627932144
-943558313
1863853911
992493420
1695155594
1868992685
1857158372
937564255
49248502
995508405
49248502
1868992685
1016008024
150564374
150564374
81332149
947424145
1049403246...

result:

ok 2153 lines

Test #22:

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

input:

3555 2669
475906260 553978288 -490496106 -184278678 751611126 -785573470 -371519627 6100376 -470113129 -269288981 -790764081 691423688 714019452 -41078966 -291568397 -322502815 -429832539 523226699 -254859277 205170185 590146470 576901869 -561831508 -297088649 416540078 -797690885 175758802 -6093019...

output:

997988349
997988349
997219765
997988349
800920736
992402137
997219765
988789044
980326185
560821460
-454957019
997988349
984311687
-454957019
997988349
724350172
-1342789258
-1342789258
961236120
995452481
988789044
407719220
997988349
147936977
407719220
558157658
997988349
997988349
992402137
9979...

result:

ok 1336 lines

Test #23:

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

input:

3635 1569
-130400556 311082269 49010742 -305718908 -282031891 519329659 -476119408 -897361826 -181003422 -165154622 -140034506 429368374 183482886 -947561971 -378459393 50837083 -700460161 -13778174 -185392330 -550861843 450001729 -135554292 298730398 -51816475 559198162 245671291 -994575398 3354672...

output:

999410032
994298910
998158715
999410032
999410032
666059880
1134726121
1268415714
995811860
856423022
1597818543
998158715
995669682
1134726121
998158715
856423022
983012748
532370287
1597818543
532370287
-754775558
995669682
532370287
998158715
995426182
765757505
1113825096
1597818543
1113825096
3...

result:

ok 786 lines

Test #24:

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

input:

47 1407
62183757 989248702 -151608173 -50351440 -228425708 667784481 -695432231 -968381943 671392854 600537718 264511615 373890725 907703330 -663329482 -493442518 408987375 494632842 518344846 -770692899 907970527 -920631265 -725192816 -36538669 525531343 370046747 607187438 512688183 202243588 -168...

output:

671243949
805067924
989248702
907970527
257650069
647806050
257650069
647806050
486338765
486338765
907970527
1392165183
678480865
1392165183
678480865
647806050
1392165183
-608650803
940612465
966083444
1553632468
1553632468
1045880436
888736861
1553632468
-112394988
-401145092
-112394988
966083444...

result:

ok 672 lines

Test #25:

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

input:

2071 4820
842858354 885016062 -559179101 -475813082 -938288584 -362217699 372376766 -968878086 954291142 401176270 717011452 99201217 270258550 -937464782 -150301979 929245341 93191923 -672112192 371970482 664262693 -552787649 -209803953 -784144059 409280035 -432810527 64965454 -478386880 -324752433...

output:

999363672
999363672
999363672
999601245
998303378
2183371180
996326849
2131271888
17131303
1953252629
894297960
999363672
2183371180
1346379908
1282351099
1355248306
2183371180
1056429587
1429208585
1335492897
2019779332
2183371180
544395813
2545010980
1686963154
544395813
2019779332
544395813
20197...

result:

ok 2370 lines

Test #26:

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

input:

4181 4346
-746596697 -337623007 -244170746 -186096824 -132520017 -716403791 320954466 246989838 -40999535 -931953793 439950805 -690956722 471316597 -312683840 -837373493 -903366661 391768320 -567281581 -480096571 624248091 -119293713 736411252 99406617 -880025196 297719762 462113344 419441801 371314...

output:

998477966
998604581
1342565294
2298469637
2298469637
-364773848
-364773848
-788031571
1748601782
1729581290
839935023
1342565294
1729581290
2296997817
-653273427
-653273427
768759496
1899294150
768759496
768759496
2298469637
2298469637
2296997817
768759496
2298469637
2298469637
-65309916
-569765290
...

result:

ok 2200 lines

Test #27:

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

input:

3236 81
-323201705 -245734748 96404276 299914033 603568376 -283062390 -700281879 350056872 236886229 -786545762 -402950370 631981330 92743303 -842701522 -348402628 37962418 106705343 -577857398 -987822340 -950355234 113187761 489221489 214233763 565047414 781579375 -104152616 591614443 735852817 305...

output:

999891724
996680441
996680441
949539259
1431246341
999590102
214548686
998796969
999891724
214548686
974949824
998796969
135264863
-286653235
-286653235
999891724
648039530
999891724
999590102
832450134
648039530
648039530
998796969
996680441
224063632
224063632
999891724
1040700185
281355642
175414...

result:

ok 42 lines

Test #28:

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

input:

704 2083
-490296889 -254001839 -467641740 -858987804 853505546 -586548817 453015036 19153815 -632279809 -475863278 596419875 -435340463 -325454392 -2590809 291831003 948079935 103686609 -334601431 490731885 39648000 -82662843 -551028997 996930393 -340855639 143862815 -182344840 423488205 209352743 6...

output:

795739125
993806518
922010875
994191705
100945925
993806518
795739125
729629556
698793117
698793117
1282867206
1408667620
1714332687
974803349
369968863
1714332687
1714332687
1198366235
1569432445
1198366235
1715627390
2475690208
2134901807
2134901807
1083725293
2035045874
2035045874
1475534760
1715...

result:

ok 1027 lines

Test #29:

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

input:

925 2924
703834759 -531810296 109165499 493659390 586212300 331596646 -891258642 599232045 989870062 -384747464 164413255 932279215 -269616785 -169783773 -689742291 648084151 230598780 623403633 989373934 467815718 -557716357 -588160031 -233815987 787233425 536763409 266535715 438157629 -296874158 5...

output:

995082896
1551518096
2404591311
949596226
995082896
977305455
999805090
997886447
2404591311
1551518096
1551518096
986937145
986306547
2411992279
2071351196
999805090
995082896
2411992279
999805090
-837010493
382186054
382186054
984921441
2411992279
619010736
-68687324
-68687324
990238266
990238266
...

result:

ok 1489 lines

Test #30:

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

input:

2027 175
-527507719 -817528983 760179545 236332456 356142308 -219011271 -238347598 -528335420 662889583 -502860573 -808275878 847775397 -700124291 -11908661 -506475878 986167261 -170579784 -500044597 310189566 646342253 135593789 -547942843 -927735396 -901288283 -284130110 -478060842 111064400 -8953...

output:

999799106
989503949
992052251
992052251
998046264
999799106
977952804
978445452
999799106
999799106
999799106
1534041325
1534041325
272517225
60212547
1917993175
60212547
-163322553
1522081468
-724950248
-60388559
982990823
999799106
1653972643
-863995847
973625618
-1236748910
-772515114
997800316
1...

result:

ok 87 lines

Test #31:

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

input:

638 2759
-935401253 764092881 -337534042 -746144487 -940775478 -677122199 657203396 324170690 358997334 49124602 -658237242 232268157 833280886 404510345 219709346 -356434448 24772466 282595014 -299364171 998491945 -219201957 994125826 684640931 -685442124 -762666464 -881827064 -525880864 -141747257...

output:

564471183
919574782
1849551503
1849551503
1849551503
1759937522
-49653551
1951302474
926294204
1951302474
582675750
928630120
928630120
928630120
928630120
928630120
582508766
582508766
1757164940
1951302474
814563094
975709180
-683669383
1951302474
224608060
977638201
243180479
436071498
436071498
...

result:

ok 1406 lines

Test #32:

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

input:

3100 2691
951876472 243770784 -714220975 649179713 -736202783 549288762 -381286711 -833212778 186481405 803553966 -919111870 -569166508 535957851 -58968908 443696734 391445894 591947777 -157074742 -271133504 -459163670 -63495887 -760431069 838665057 -355253659 881282217 785309913 -711259654 38517561...

output:

999633517
998397200
-370507080
972584759
207784377
992762561
923141077
999781365
-370507080
999633517
985851272
443541222
994946656
999633517
431750001
995677094
999975751
999975751
-14070402
-14070402
1829781572
999975751
186082228
999633517
186082228
708387072
998397200
992819833
999975751
7241501...

result:

ok 1327 lines

Test #33:

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

input:

3772 485
-619950735 -818824476 749459768 963344764 -982500477 -667677004 45425887 -15411819 422977166 549646818 -993379923 151776936 502566495 -185491548 243859489 -788136503 339210637 -842817571 287311380 -642234465 -141555292 -563951044 -576736895 -704731692 123203112 37060876 344465989 -598258761...

output:

984622000
998805178
994479930
951625170
1248266901
935156128
1245126501
1036842576
1245896275
1036842576
983480796
1246137446
1248266901
998056353
836558507
994479930
1248266901
836558507
1248266901
1787237483
1921408068
1601083469
1930376588
1934159772
1578410303
2477432690
2477432690
-378298676
90...

result:

ok 253 lines

Test #34:

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

input:

3639 3445
-546686814 687218592 -706993616 -685218576 -556967584 -371402371 740118730 -529458937 418032281 48814127 -571966871 692673651 460238856 -501309501 -584725124 870735577 -174243124 -833683954 -783648988 263733987 807363459 45933375 -183067218 -858909648 -720268020 -778517820 -874725152 44721...

output:

996580398
1251195824
999195986
999983359
999983359
999195986
1701018480
1613682573
1615028477
1701018480
220110447
1701018480
964286773
1283274143
1615028477
978347600
-790384978
641818723
124542808
-2065302534
124542808
-641739219
1283274143
1283274143
957932574
848621180
213767935
589587631
589587...

result:

ok 1723 lines

Test #35:

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

input:

4513 554
-17222416 289743817 497214418 -636288221 -504903363 81334580 781172448 975641475 -612194641 -494973908 -800815357 967890769 477755249 -14503778 -851339203 537344906 689034519 505609515 -722310231 -489387914 -208917854 -559475509 901423702 816415992 -572937356 -944913291 -188121610 935112124...

output:

999525385
998009759
999525385
999525385
996549384
1941219616
1966616031
1966616031
1922500004
999525385
790538491
1941219616
1913620185
1966616031
1966616031
1966616031
1941219616
1966616031
1216479982
998974364
1216479982
998974364
1941219616
530359061
2905539519
2845687909
1927575869
2928436009
14...

result:

ok 299 lines

Test #36:

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

input:

720 3428
-396742784 229901192 -724392889 -357140375 -611541119 -887588060 539881598 888028019 714586817 -284206637 -430922043 517580564 367268871 -530769415 37853907 181450068 331183540 614796188 530270806 664578450 -944485116 -361570067 851368602 734011863 -943344274 304197389 -469009842 -244672713...

output:

996159495
817987536
1073248059
608577473
962317774
1073248059
233121212
962317774
-775292769
865744579
-775292769
140932135
1073248059
-775292769
161077618
1073248059
1073248059
161077618
888028019
1073248059
527087676
998392400
998392400
-961353078
1073248059
987814621
998392400
1073248059
58281627...

result:

ok 1730 lines

Test #37:

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

input:

3117 3797
648212118 154697848 -868201426 687545801 -384547097 -51647261 399748278 33856841 284180557 -654663729 959068331 -894540214 -594612079 94236335 -259262856 -129788753 -47263489 -994848940 -117674670 -853685569 -173323173 378837536 314113046 957990604 -452399374 89452991 595880284 999666373 1...

output:

977922712
983594784
1250682001
1264604970
979852056
1264604970
973434875
1264604970
702533601
1264604970
-291156033
998597317
972843793
998597317
1262098243
977115810
-386309112
492632412
1264604970
972588983
1264604970
243897830
-382041699
978575712
929118700
1264604970
957286993
974044749
12646049...

result:

ok 1930 lines

Test #38:

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

input:

394 2904
-379185278 961728773 598605631 -366552927 -68544043 580756616 874570404 -408316349 -15882007 -663999980 263355040 -326037784 -390442442 -906044519 672082190 266790012 -460864741 70653267 -277351980 -525109739 -556358361 -244330293 30222380 -533771182 78757333 338557328 -621998482 858623439 ...

output:

995491981
995491981
898438647
986934074
996369212
995491981
920324355
937679274
986934074
996369212
995491981
996369212
802779270
1014367897
995491981
1014367897
817740454
79742852
383472617
1920565082
1303141513
-100351518
874570404
-100351518
995491981
1920565082
445083882
1920565082
955677959
-10...

result:

ok 1425 lines

Test #39:

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

input:

2920 335
-120087179 -541802955 881819002 -599501326 376155148 426616332 790975063 950122818 -302818827 293334907 -925602751 96046299 600659415 -267598855 -143501536 -664048164 -4972967 -168881631 423610582 -385788112 302973091 -760730763 227210050 535072442 -298813620 875463342 -667807936 241114864 ...

output:

995450238
350114194
992335096
990687520
998336338
351514297
351514297
351514297
995450238
998336338
998336338
998336338
998336338
980600328
978513283
-123571554
1009267976
1731481562
2275518329
2275518329
-273072073
-943783542
2272640392
355080220
1932757549
190430634
1932757549
2275518329
227551832...

result:

ok 173 lines

Test #40:

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

input:

224 4790
646927297 -684318532 228781691 -719616540 848775824 671838061 -491354511 -3799928 -210696758 -690650249 -170037989 -216134286 304389225 -934456694 375485556 871956092 654554285 -297380771 -62995190 -651509876 114750978 -753911351 -786058900 -201154345 254796702 453816366 -481310213 59184983...

output:

1422477298
1399575469
1365416091
812578395
1422477298
1422477298
806504622
1591455997
812578395
1422477298
812578395
1422477298
1591455997
1591455997
717935620
1591455997
1718750647
1718750647
823658151
1591455997
1718750647
1585382224
1591455997
1585382224
1585382224
1625441273
-587246656
162410787...

result:

ok 2445 lines

Subtask #2:

score: 20
Accepted

Test #41:

score: 20
Accepted
time: 199ms
memory: 18368kb

input:

121052 321981
-596311509 97956406 349856095 -686034642 737492651 -694236792 15693335 -366636068 -776777424 210304150 738103859 550794499 -379456360 -88686071 -292136232 -19017723 562249023 989340516 583026310 245653395 -592847180 94449564 -92535990 795876869 -596857169 844758661 148306335 -209612916...

output:

999811592
999811592
999993316
999990320
999811592
999811592
999990320
999993316
999990320
999811592
-638504628
999811592
999993316
999515044
999811592
999990320
999990320
999515044
999990320
996755018
999515044
-638504628
999811592
999990320
999282460
-961407077
999873734
999811592
999990320
9999903...

result:

ok 241687 lines

Test #42:

score: 0
Accepted
time: 182ms
memory: 11496kb

input:

27611 346251
-803041179 488860442 -583060124 473186837 -718799118 -626918602 464745042 -832042416 -255426133 -688784925 -426387763 -478458879 880084763 512518607 317809911 -897824851 328310793 599707263 -458981380 -70601152 913659203 602163096 733961612 -980033625 -938443501 826942360 350063688 -841...

output:

999184506
999665895
999665895
999234965
993370004
999660612
999983147
999665895
923256885
999983147
996649928
999922165
999922165
997234107
999234965
999665895
999983147
998075008
999234965
999695339
996642418
927649979
999695339
999983147
999922165
999234965
999665895
-157349444
998844772
999274164...

result:

ok 259876 lines

Test #43:

score: 0
Accepted
time: 422ms
memory: 51336kb

input:

500000 500000
-271349870 -481909746 789057625 -20055212 -415673993 -661666211 -273891472 820401141 -579393624 -689475416 -96406291 -330971903 115368887 -987417519 690564341 -638342429 133602622 696994441 -417189386 -690833991 480125508 777475733 -521662799 -99154686 679371795 289571147 -943812700 82...

output:

999999730
999848192
999975023
999984706
998941140
998988001
999984706
999633488
-153564471
999984706
999999730
-203637439
999999730
999848192
88421001
88421001
999984706
999999730
999999730
999999730
999997342
999939375
999999730
357293183
999997303
999999730
999999730
999997342
999711382
88421001
3...

result:

ok 374470 lines

Subtask #3:

score: 20
Accepted

Test #44:

score: 20
Accepted
time: 202ms
memory: 31672kb

input:

229251 323498
611450532 966767646 -297353767 454277388 -573850612 -393051192 -971634382 148709713 631057007 -115295372 674054747 377709092 -512864995 -872184376 608610911 903466194 -83086298 218581982 -250300982 -875187359 -360458784 26872429 140007127 -224821886 689238671 -786936170 -204172695 -300...

output:

999993020
999993020
999912081
999992657
999977852
999992657
999993020
1003078567
999993020
999761309
999993020
1495925707
1493082668
-732442985
1492931896
1495668375
999993020
1495668375
1492931896
999977852
-111449865
999890399
999993020
1495925707
-732979402
1493082668
-1251909861
-1251909861
1495...

result:

ok 242560 lines

Test #45:

score: 0
Accepted
time: 186ms
memory: 11872kb

input:

24362 426983
-271169360 230063385 -613683942 -696572934 363160394 178280734 -89053352 912119380 975399359 -938252090 -60398504 -868174320 635401799 -379719928 400144142 -461160670 -534034944 110393445 -548215389 -575752061 -523835037 526604566 89432507 806612784 591373855 581731219 300334044 -228240...

output:

999913992
998215345
999913992
999913992
999913992
999913992
999063787
1647947630
999733836
1694358309
996057315
999913992
1694358309
999913992
997938341
984413138
1879878474
2453395374
1643226120
1743612734
2461543664
1566001749
2036304180
2461543664
2036304180
1737428485
1877410593
2461543664
24601...

result:

ok 320526 lines

Test #46:

score: 0
Accepted
time: 337ms
memory: 53316kb

input:

500000 500000
502936699 625884945 931849661 534981820 -63055775 -583643978 574838037 668262128 356893703 -597341007 338092370 -657778022 -175110367 -167786214 105115256 757539185 -553774069 -848422737 687071288 -18754486 732397731 -667407991 735598598 558959559 -60673681 768149586 732722819 28066772...

output:

999968731
999992532
999968731
1070750934
1070727133
1070727133
1070750934
1070750934
1070717781
1070716090
-143096890
39187875
1070642291
1070571466
1070717781
1070750934
1070727133
-142717841
1070716090
642335755
1070727133
1070750934
1168169055
1168169055
1070642291
999981945
1070717781
1168169055...

result:

ok 374926 lines

Test #47:

score: 0
Accepted
time: 367ms
memory: 53280kb

input:

500000 500000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 ...

output:

111343988913740

result:

ok single line: '111343988913740'

Subtask #4:

score: 50
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #48:

score: 50
Accepted
time: 492ms
memory: 53384kb

input:

500000 500000
270792064 -733595993 -997745414 -8770423 -792259754 5753883 552266102 464291983 321592810 300040100 387849148 11889325 854968477 -54561632 -22270788 -658195045 -493465032 297991358 -450152210 682919035 -910940854 -506171984 322273880 -508023195 -192874340 712388039 320343269 -399958528...

output:

1894541962
154732244
1049295937
999980430
999980430
409195615
1894541962
437320197
1894541962
1051379293
999914548
999980524
1051379293
1051379293
999968797
437320197
1894541962
1894541962
437320197
437320197
1894541962
1894541962
1232239314
999959775
304477413
319854043
1894541962
1269601335
751731...

result:

ok 249997 lines

Test #49:

score: 0
Accepted
time: 146ms
memory: 31648kb

input:

189664 165597
-459632512 -1267366 -573832598 445217062 820958872 -235011034 -803999017 456782764 868801673 275395710 -737586495 -232055151 -496732920 134737522 520170302 -373617412 -718316348 125179551 -857438477 891494925 639058468 -182270337 -667271595 415809872 -234265974 -3366030 476899915 52935...

output:

999994916
999875023
999890393
999996652
999982211
947123353
1070845745
1070845745
404723526
1387481473
2053603692
2104564719
2104564719
2104564719
2104564719
2356675410
2356675410
3073758656
3073758656
2356675410
3073758656
1953537164
3022797629
3073758656
3835875972
3835875972
999732916
4746262038
...

result:

ok 83127 lines

Test #50:

score: 0
Accepted
time: 120ms
memory: 52408kb

input:

368787 107327
-879375797 773314546 154454132 -85036 -815690081 333870968 -309151125 590741170 514229253 -260527767 -548504079 567220158 437530840 -404061669 -154033097 -579535144 490470737 -443179622 320899301 470798234 -430582898 276120033 268877807 -557736422 -987601702 560832194 -376360370 529410...

output:

999999123
999936697
999848908
999997430
856885952
999955780
999968694
167535735
857212022
999999123
999817231
999782990
24597728
999968694
-215619037
733316791
999695966
999999123
999999123
1491518845
1149820953
1491518845
1570509170
1570810634
127644445
1109476313
127644445
1089145630
207247397
572...

result:

ok 53671 lines

Test #51:

score: 0
Accepted
time: 497ms
memory: 52972kb

input:

500000 500000
-673484114 -757861414 -699772694 -149886832 979835309 594972212 793639543 -703201552 457320416 -104585390 577296617 496355639 -149305772 498449651 345432064 772610497 235885704 627008140 264373277 -968128887 857231860 -733142319 229864950 -302959792 935669312 18456361 488373097 -934579...

output:

999999742
1711447701
1711447701
1711447701
492533311
1711447701
1204030751
1711447701
1204030751
618911603
1711447701
1709939835
999984774
1568487091
1203210202
1711447701
285502032
1711447701
1204030751
632647820
1711447701
1711447701
1392197986
1711447701
-991639910
1392197986
1711447701
632647820...

result:

ok 249722 lines

Test #52:

score: 0
Accepted
time: 244ms
memory: 15924kb

input:

64260 364700
341514256 987149968 -615244955 -626733230 -378001882 -620850810 -753371555 -178429294 -637278095 -287219626 -384596319 -842313297 628996331 -577673551 330535695 -990125950 775779575 299176944 -702144503 304999490 -975606643 -778094536 393571001 36331895 502302753 733118849 -311442251 -2...

output:

999254639
999874124
998853153
999254639
998853153
999963951
999951653
-312412734
999786690
933773109
674442765
1465578521
999963951
1465578521
1513773152
1164376242
999963951
780398733
780398733
1465578521
1710211917
1513773152
258121672
879735942
999902183
879735942
780398733
1513773152
1710211917
...

result:

ok 182393 lines

Test #53:

score: 0
Accepted
time: 344ms
memory: 31204kb

input:

204774 409005
599818754 -884222483 -416205539 -550482792 -947121942 -444722310 108778226 380949960 -257639004 -579370883 -488289969 148811029 -549329020 -6281130 -320732945 -916096650 -377682094 -684796980 551467788 95785404 -695420753 135855872 -82917647 477356857 -466727241 -639804413 -858842432 -...

output:

999990443
999955322
999990443
985565714
999990443
999870376
999478808
1382085108
1180522896
1180522896
1288309115
1180522896
1382085108
1180522896
1382085108
1180522896
153641902
1382085108
153641902
1382085108
1180522896
999628940
543313272
999628940
1288309115
-307093910
619287703
999870376
138208...

result:

ok 204597 lines

Test #54:

score: 0
Accepted
time: 501ms
memory: 53104kb

input:

500000 500000
848774619 -845140599 -953248168 367166600 902697692 677680297 470406568 583476284 302930916 85908639 -863705501 -87492213 -210897573 -667545640 -774799357 -425369382 -861677398 78014766 -174162026 -192789767 157036404 110057817 -510520737 466060773 938108019 -437057403 311043677 -42033...

output:

999979431
999997944
999979431
628089454
662082355
679744041
999994613
1389356431
679744041
1389356431
-282097676
290934924
679744041
1389356431
1389356431
1389356431
1216597205
1389356431
-91589931
1252440670
1252440670
-78119412
1389356431
628089454
1252440670
38321815
-363181254
999994613
12524406...

result:

ok 250543 lines

Test #55:

score: 0
Accepted
time: 44ms
memory: 53132kb

input:

467662 28101
636673940 66249237 -335236579 763595941 605782864 241350332 -82085703 -751396826 137151738 -230884487 -149169099 557315991 433271939 759118247 -137865478 -462663573 170035032 325635612 787723111 -910449980 301321887 -998462034 -935707445 609158274 856389031 -641800571 176274317 -5258668...

output:

999989184
999989184
999804190
999938877
999989184
999979864
999989184
1583919449
2576934835
999979864
2576934835
1583869142
2576919001
2576919001
1879128447
2576934835
2576919001
2576934835
1178953937
636994234
1295080666
1352536913
2576934835
1998494463
330495474
999983394
999983394
-913225706
2837...

result:

ok 14016 lines