QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#431975 | #4878. Easy Problem | grass8cow | TL | 1670ms | 5932kb | C++17 | 1.0kb | 2024-06-06 14:41:56 | 2024-06-06 14:41:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,L[100100],m,R[100010];
ll c[101000],su[101000],ans[101000];
ll val(int l,int r,int t){
ll s=0;
for(int j=1;j<=m;j++)if(l<=L[j]&&L[j]<=t&&t<=R[j]&&R[j]<=r)s+=c[j];
return s-(su[r]-su[l-1]);
}
void cdq(int l,int r,int xl,int xr,int yl,int yr){
if(l>r)return;
int mi=(l+r)>>1,X,Y;
ll mx=-1e18;
for(int i=xl;i<=min(xr,mi);i++)for(int j=max(yl,mi);j<=yr;j++)
if(mx<val(i,j,mi))
mx=val(i,j,mi),X=i,Y=j;
ans[mi]=max(mx,0ll);
cdq(l,mi-1,xl,xr,yl,yr);
cdq(mi+1,r,xl,xr,yl,yr);
}
ll cf[101000];
void sol(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%lld",&su[i]),su[i]+=su[i-1],cf[i]=0;
for(int i=1;i<=m;i++)scanf("%d%d%lld",&L[i],&R[i],&c[i]),cf[L[i]]+=c[i],cf[R[i]+1]-=c[i];
cdq(1,n,1,n,1,n);
for(int i=1;i<=n;i++)cf[i]+=cf[i-1],printf("%lld ",cf[i]-ans[i]);
puts("");
}
int main(){
int T;scanf("%d",&T);while(T--)sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5876kb
input:
1 4 3 3 3 2 2 1 2 2 3 3 3 2 2 4
output:
2 5 2 0
result:
ok 4 number(s): "2 5 2 0"
Test #2:
score: 0
Accepted
time: 3ms
memory: 5932kb
input:
200 10 10 441129649 175970039 478629746 150210377 473385687 400931249 155714650 270352812 293555449 444876725 1 1 114317839 1 1 158354349 1 4 13054554 1 3 562005243 1 3 114310710 1 1 481426141 1 2 150800722 1 1 224503966 2 3 106234607 1 2 6235654 10 10 216212720 595995796 317909277 459839404 7779474...
output:
1108783988 952641490 795605114 13054554 0 0 0 0 0 0 608974640 444907672 198220395 146074643 98876749 98876749 0 0 0 0 705855899 1806578664 1806578664 1087055465 1097923412 658626033 0 0 0 0 1317049808 1333896443 1333896443 1130264137 705133476 705133476 244998554 244998554 244998554 0 650384552 ...
result:
ok 2000 numbers
Test #3:
score: 0
Accepted
time: 12ms
memory: 5872kb
input:
70 28 28 299340757 599163086 479724314 553373673 145370014 449023488 239828280 464547162 564617481 386788885 538072218 336574202 509700840 260000237 268218492 205809003 488992076 71498927 295908965 44608221 292458381 266918504 40046299 405753946 167337570 198865640 496122952 543209246 5 9 391702331 ...
output:
1235779916 1768292605 2109280695 2359711223 2405196868 2123670563 1768854560 1380797414 1238518374 278712450 278712450 278712450 231436975 196429714 196429714 196429714 0 0 0 0 0 0 0 0 0 0 0 0 2302336351 2675990660 3187926354 3192222346 3364716631 2662585211 2408759307 2211771249 1696281402 9760642...
result:
ok 1960 numbers
Test #4:
score: 0
Accepted
time: 1638ms
memory: 5876kb
input:
10 200 200 299033703 19649886 450325950 482223075 248052091 395331620 572513571 267142029 218785235 34042552 290536701 299995691 293820663 43235625 560205909 130244099 454253406 151897732 185348562 330028326 451777736 580255995 446945889 481094104 428101716 350315144 51275596 479535003 298489189 360...
output:
2154894760 4199376091 5796781394 6737814223 8420742145 8914942062 10381605876 10520258167 10892708803 12006419441 11977947406 12529541411 13183556633 13218927651 13183507867 13287383363 12980564168 12972527881 12847282036 14133445977 14969437777 15457763699 15547495412 14417815800 13792861110 139988...
result:
ok 2000 numbers
Test #5:
score: 0
Accepted
time: 1637ms
memory: 3828kb
input:
10 200 200 595356907 443448658 460461205 450742489 519384409 307395926 165352831 339038683 427285121 426550807 509134731 379144832 570498910 333295057 174436429 506785283 385756684 320737549 495579424 454968196 418665180 481240461 369995678 514644016 535052542 418582649 281534233 248733994 390402184...
output:
1225078551 2997561317 3899585942 5204205468 6383949036 7229364885 8066807243 8306523436 8570996997 9525764487 10977828851 12142506978 12869530266 13737037591 14810936387 15104498076 15666580157 15508122964 14633651671 14519418762 14611216840 15218444516 16202857784 15238271521 15694077349 1583991999...
result:
ok 2000 numbers
Test #6:
score: 0
Accepted
time: 1670ms
memory: 5828kb
input:
10 200 200 24460166 28276704 270150308 175177963 13861942 310904352 210747485 265173556 408994772 124097238 115367001 176436386 75904658 43096507 101591862 504938289 397312266 284971444 84810208 107312069 170434853 53667321 31695817 30332703 136185925 2398490 11478728 274487327 147259442 71604184 24...
output:
1725076274 2659549622 4067804646 5163190804 6363193694 8085344355 8853204563 9097037689 9741400351 10160594403 10347739813 10586325097 10586325097 11663449216 11673324990 12185298414 12269774191 12447842154 12651295393 12801274970 12801274970 13283817756 13374032325 13402831907 13402831907 138362208...
result:
ok 2000 numbers
Test #7:
score: -100
Time Limit Exceeded
input:
1 2000 2000 6011813 213667239 5945093 187762583 475936831 378905220 594349904 310225141 122190242 250514358 8077992 181412851 9134031 104423717 419143617 359383615 252871346 30732778 530106662 513365192 404086553 104790142 451175600 136377140 365671895 56813665 408910185 460180739 505332700 54193785...