Asher12 @ 2023-07-15 11:28:21
加上快读后:
#include <iostream>
using namespace std;
int xue[5000010];
int c[5000010];
inline int read()
{
int sum=0,sign=1;
char ch=getchar();
if(ch<'0'||ch>'9')
{
if(ch=='-')
{
sign=-1;
ch=getchar();
}
}
while(ch>='0'&&ch<='9')
{
sum=sum*10+ch-'0';
ch=getchar();
}
return sum*sign;
}
void cf(int a,int b,int c1)
{
c[a]+=c1;
c[b+1]-=c1;
}
int main() {
int n,p,minx=100000010;
cin>>n>>p;
for (int i=1;i<=n;i++)
{
xue[i]=read();
}
for(int i=1;i<=n;i++)
{
c[i]=xue[i]-xue[i-1];
}
for (int i=1;i<=p;i++)
{
int a,b,c;
a=read();
b=read();
c=read();
cf(a,b,c);
}
for (int i=1;i<=n;i++)
{
xue[i]=xue[i-1]+c[i];
minx=min(minx,xue[i]);
}
cout<<minx<<endl;
return 0;
}
by abc17792plum @ 2023-07-15 11:48:43
@Asher12 getchar没有头文件啊cstdio
by abc17792plum @ 2023-07-15 12:32:22
@Asher12
#include <iostream>
#include<cstdio>
using namespace std;
int xue[5000010];
int c[5000010];
inline int read()
{
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')
{
f=-1;
}
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
void cf(int a,int b,int c1)
{
c[a]+=c1;
c[b+1]-=c1;
}
int main()
{
int n,p,minx=100000010;
cin>>n>>p;
for (int i=1; i<=n; i++)
{
// cin>>xue[i];
xue[i]=read();
}
for(int i=1; i<=n; i++)
{
c[i]=xue[i]-xue[i-1];
}
for (int i=1; i<=p; i++)
{
int a,b,c;
a=read();
b=read();
c=read();
// cin>>a>>b>>c;
cf(a,b,c);
}
for (int i=1; i<=n; i++)
{
xue[i]=xue[i-1]+c[i];
minx=min(minx,xue[i]);
}
cout<<minx<<endl;
return 0;
}
by Asher12 @ 2023-07-15 13:34:47
@abc17792plum ! AC
!
by abc17792plum @ 2023-07-15 13:35:35
@Asher12 但你没加头文件就会CE啊QAQ
by Asher12 @ 2023-07-15 13:35:42
@abc17792plum 我忘了只有scanf
和printf
不用
by abc17792plum @ 2023-07-15 13:36:44
@Asher12 把同步流关了!
by Asher12 @ 2023-07-15 13:37:23
@abc17792plum 表情怎么打啊
by abc17792plum @ 2023-07-15 13:38:17
@Asher12 exlg
by FENGHAOZHE1234 @ 2023-07-15 16:44:51
头文件可以统一用#include<bits/stdc++.h>(但最好还是一个个打)。
by dingzj2022 @ 2023-07-23 16:37:47