QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#431978#4878. Easy Problemgrass8cowWA 2ms5944kbC++17983b2024-06-06 14:44:042024-06-06 14:44:06

Judging History

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

  • [2024-06-06 14:44:06]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5944kb
  • [2024-06-06 14:44:04]
  • 提交

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){
    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=mi;j<=n;j++)
        if(mx<val(i,j,mi))
            mx=val(i,j,mi),X=i;
    ans[mi]=max(mx,0ll);
    cdq(l,mi-1,xl,X);
    cdq(mi+1,r,X,xr);
}
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);
    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: 5780kb

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: 2ms
memory: 5944kb

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'