QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#431974 | #4878. Easy Problem | grass8cow | WA | 3ms | 5956kb | C++17 | 1.0kb | 2024-06-06 14:41:30 | 2024-06-06 14:41:31 |
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,X,yl,Y);
cdq(mi+1,r,X,xr,Y,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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5832kb
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: -100
Wrong Answer
time: 3ms
memory: 5956kb
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:
wrong answer 56th numbers differ - expected: '2864942117', found: '2885162141'