60求助
查看原帖
60求助
836448
stylus楼主2024/10/23 19:23

思路:
因为点定,查看左右区间最大左边+右边
代码:

#include<bits/stdc++.h>
#define int long long
using namespace std;
void read(int &x){
	x=0;bool f=0;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-')f=1;
		ch=getchar();
	}do{x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}while(ch>='0'&&ch<='9');
	x=f?-x:x;
}
int n,a,b,s,z;
signed main(){
	read(n);
	while(n--){
		read(a),read(b);
		s=max(s,b),z=max(z,a-b);
	}cout<<s+z;
	return 0;
}
2024/10/23 19:23
加载中...