1047B Cover Points

版权声明:大家一起学习,欢迎转载,转载请注明出处。若有问题,欢迎纠正! https://blog.csdn.net/memory_qianxiao/article/details/82830284

B. Cover Points

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

There are nn points on the plane, (x1,y1),(x2,y2),…,(xn,yn)(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 nn (1≤n≤1051≤n≤105).

Each of the next nn lines contains two integers xixi and yiyi (1≤xi,yi≤1091≤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

Copy

3
1 1
1 2
2 1

output

Copy

3

input

Copy

4
1 1
1 2
2 1
2 2

output

Copy

4

Note

Illustration for the first example:

Illustration for the second example:

题意:给了n个点的坐标,需要用等边三角形把这些点全部围住。输出边长最短的长度。

题解:数论  经过多次模拟发现,答案是横纵坐标的和里面的最大值

c++:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,x,y,ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>x>>y,ans=max(ans,x+y);
        cout<<ans;
    return 0;
}

python:

n=int(input())
ans=0
for i in range(n):
    x,y=map(int,input().split())
    ans=max(ans,x+y)
print(ans)

猜你喜欢

转载自blog.csdn.net/memory_qianxiao/article/details/82830284