数据太水

P2367 语文成绩

@[zombiell810975](/user/1104479) 没过就行
by AKCSPER @ 2024-03-05 19:17:42


@[zombiell810975](/user/1104479) $p\le n$ 所以可以认为在极限数据下 $p=n$,~~所以可以将 $p$ 写成 $n$。~~
by QWQ_123 @ 2024-03-05 19:22:22


尴尬的第二个注释打错了,是i<=n变为了i<=k(i<=p).
by zombiell810975 @ 2024-03-05 19:30:46


@[zombiell810975](/user/1104479) ```cpp #include<bits/stdc++.h> using namespace std; int n,p; int x,y,z; int a[100005],s[100005]; int read(){ int f=1,k=0; char c=getchar(); while(c<'0'||c>'9'){ if(c == '-') f=-1; c=getchar(); } while(c>='0'&&c<='9'){ k = k * 10 + c-'0'; c=getchar(); } return f*k; } int main(){ n=read(); p=read(); for(int i=1;i<=n;i++){ a[i]=read(); s[i]=a[i]-a[i-1]; } for(int i=1;i<=p;i++){ x=read(),y=read(),z=read(); s[x]+=z; s[y+1]-=z; } int t=s[1],res=s[1]; for(int i=2;i<=n;i++){ t+=s[i]; res=min(t,res); } cout<<res; return 0; } ``` 不知道哪有错误,如果大佬有时间的话,帮帮——,谢谢佬
by laugh_001 @ 2024-03-05 23:52:22


|