szhl0803 @ 2022-07-08 17:05:00
玄学……
//P2367 语文成绩
#include <bits/stdc++.h>
#define N 500005
using namespace std;
int a[N],b[N];
int n;
void run()
{
for(int i=1;i<=n;i++)
b[i] = a[i] - a[i-1];
}
int main()
{
int p ;
cin>>n>>p;
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
run();
while(p--)
{
int x,y,q;
scanf("%d%d%d",&x,&y,&q);
b[x]+=q;b[y+1]-=q;
}
long long ans = LONG_LONG_MAX;
for(int i=1;i<=n;i++)
{
b[i] += b[i-1];
ans = min(1ll*b[i],ans);
}
cout<<ans;
return 0;
}
by _Haoomff_ @ 2022-07-08 17:19:38
@szhl0803
1.
b[i] += b[i-1]
应是
a[i] = a[i-1]+b[i]
2.不用开longlong
3.run函数完全可以省掉
by szhl0803 @ 2022-07-08 17:20:43
@Haoomff 谢谢
by Ja50nY0un9_as_AgNO3 @ 2022-07-08 17:22:28
by Ja50nY0un9_as_AgNO3 @ 2022-07-08 17:22:51
@szhl0803
by szhl0803 @ 2022-07-08 17:25:26
@123zz
by szhl0803 @ 2022-07-08 17:26:39
@1234zz 我重复,我没有举报你,你认错人了。