80pts求调。。

P2367 语文成绩

freeshare @ 2024-10-05 22:33:01

rt

#include <bits/stdc++.h>
using namespace std;
int d[5000005],a[5000005],minn=0x7f7f7f7f;
int n,p,x,y,z;
int main()
{
    cin>>n>>p;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        d[i]=a[i]-a[i-1];
    }
    for(int i=1;i<=p;i++){
        cin>>x>>y>>z;
        d[x]+=z;
        d[y+1]+=z;
    }
    for(int i=1;i<=n;i++){
        d[i]=d[i-1]+d[i];
        minn=min(minn,d[i]);
    }
    cout<<minn<<endl;
    return 0;
}

by bladrrxy @ 2024-10-05 22:56:02

d[x]+=z;
d[y+1]+=z;

这是怎么回事。。。 @freeshare


by freeshare @ 2024-10-06 11:27:52

@bladrrxy WC,谢谢大佬,已ac。(这错误居然还能80


|