Instance_Fail @ 2022-11-24 19:58:30
#include<bits/stdc++.h>
#define MAXN 5000009
#define INF 1e9
using namespace std;
int n,p,x,y,z,a[MAXN],b[MAXN],ans=INF;
int main(){
// ios::sync_with_stdio(false);
// cin.tie(0);
cin>>n>>p;
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
for(int i=1;i<=n;i++){
b[i]=a[i]-a[i-1];
}
for(int i=1;i<=p;i++){
cin>>x>>y>>z;
b[x]+=z,b[y+1]-=z;
}
for(int i=1;i<=n;i++){
a[i]=a[i-1]+b[i];
ans=min(ans,a[i]);
}
cout<<ans;
return 0;
}
为什么加上注释的两句会让这道题WA掉
by VitrelosTia @ 2022-11-24 20:00:43
@Instance_Fail 因为你用了scanf
by feng_column @ 2022-11-24 20:01:52
因为用了scanf不能用ios去同步
by Instance_Fail @ 2022-11-24 20:03:21
@VT_SODC3DC3BSLF 知道了,谢谢
by CH_mengxiang @ 2022-11-24 20:34:18
@Instance_Fail
ios::sync_with_stdio(false);
用于取消C++和C语言输入输出同步的,此时输入和输出有一个混用了就会出问题