caidaokoujiao @ 2023-04-29 16:29:23
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int n,q;
int a[N],b[N];
void insert(int l,int r,int c){
b[l]+=c;
b[r+1]-=c;
}
int main(){
cin>>n>>q;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
insert(i,i,a[i]);
}
while(q--){
int l,r,c;
cin>>l>>r>>c;
insert(l,r,c);
}
for(int i=1;i<=n;i++){
b[i]+=b[i-1];
}
int Max=1000;
for(int i=1;i<=n;i++){
if(b[i]<Max){
Max=b[i];
}
}
cout<<Max;
}
by hanpiikun @ 2023-04-29 16:39:45
额,看提示
对于
by hanpiikun @ 2023-04-29 16:41:59
对于runtime error,我目前只知道越界,和数组开太小才会出runtime error
by hanpiikun @ 2023-04-29 16:42:59
把const int N=100010;改为const int N=5000010;
by ___njr___ @ 2023-05-20 21:16:14
@hanpiikun
使用throw
没有catch
也是RE,除0也算,指针非法访问也是。
by hanpiikun @ 2023-05-21 08:09:00
@liuhaodong2021 感谢大佬