【题解】codeforces1047B[Codeforces Round #511 (Div. 2)]B.Cover Points 数学知识

32 篇文章 0 订阅
32 篇文章 0 订阅

题目链接

Description

There are n n n points on the plane, ( x 1 , y 1 ) , ( x 2 , y 2 ) , … , ( x n , y n ) (x_1,y_1),(x_2,y_2),…,(x_n,y_n) (x1,y1),(x2,y2),,(xn,yn).

You need to place an isosceles triangle with two sides on the coordinate axis to cover all points (a point is covered if it lies inside the triangle or on the side of the triangle). Calculate the minimum length of the shorter side of the triangle.

Input

First line contains one integer n (1≤n≤105).

Each of the next n lines contains two integers xi and yi (1≤xi,yi≤109).

Output

Print the minimum length of the shorter side of the triangle. It can be proved that it’s always an integer.

Examples

Input

3
1 1
1 2
2 1

Output

3

Input

4
1 1
1 2
2 1
2 2

Output

4

Note

Illustration for the first example:
在这里插入图片描述
Illustration for the second example:
在这里插入图片描述


假设最后答案为 l l l,则对于 ∀ ( x , y ) \forall (x,y) (x,y) x + y − l ≤ 0 x+y-l\leq0 x+yl0,化简得 l ≥ x + y l\geq x+y lx+y x + y x+y x+y 的最大值即为所求。

#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	//freopen("in.txt","r",stdin);
	int n,x,y,maxn=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	    scanf("%d%d",&x,&y),maxn=max(maxn,x+y);
	printf("%d\n",maxn);
	return 0;
}

总结

偏要用线性规划做。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值