帮帮弱鸡

P2367 语文成绩

wjm2012 @ 2024-12-03 12:46:29

#include<iostream>
using namespace  std;
int n,p,a[10000],x,y,z;
int  main(){
    int xiao=10000;
    cin>>n>>p;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=p;i++){
        cin>>x>>y>>z;
        for(int j=x;j<=y;j++){
            a[j]+=z;
            x=min(x,a[j]);
        }
    }
    cout<<x;
return 0;
}

为什么0分?


by Angeltears @ 2024-12-03 12:52:29

微调(求关

#include<iostream>
#include<cstdio>
using namespace std;
int n,q,d[5000005]={0},a,minn,x,y,z;
int main()
{
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++)scanf("%d",&d[i]);
    for(int i=n;i>1;i--)d[i]-=d[i-1];
    while(q--)
    {
        scanf("%d%d%d",&x,&y,&z);
        d[x]+=z;d[y+1]-=z;
    }
    minn=d[1];
    for(int i=2;i<=n;i++)
    {
        d[i]+=d[i-1];if(d[i]<minn)minn=d[i];
    }
    cout<<minn;
    return 0;
}

|