全WA了,求佬们看看哪里有问题

P2367 语文成绩

shuatijiqi @ 2023-07-14 09:52:18

#include <stdio.h>

#define N 5000010

int a[N],d[N],ans=1000;

int main(){
    int n,p;
    scanf("%d%d",&n,&p);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }

    for(int i=1;i<=n;i++){
        d[i]=a[i]-a[i-1];
    }

    while(p--){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        d[x]+=x;
        d[y+1]-=z;
    }

    for(int i=1;i<=n;i++){
        a[i]=a[i-1]+d[i];
        if(a[i]<=ans){
            ans=a[i];
        }
    }

    printf("%d",ans);

    return 0;
}

by Elairin176 @ 2023-07-14 09:53:49

@shuatijiqi
[x,y] 增加 z


by shuatijiqi @ 2023-07-14 09:55:41

看见了,我眼瞎了hhh


|