码迷,mamicode.com
首页 > 其他好文 > 详细

1047B_Cover Points

时间:2018-10-02 17:58:14      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:scan   cat   最小   prope   example   ica   三角形   printf   ret   

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 (1n1051≤n≤105).

Each of the next nn lines contains two integers xixi and yiyi (1xi,yi1091≤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:技术分享图片

题意:唔就是,让你找到一个最小的等腰三角形,使得给出的所有点都包含在等腰三角形里或者等腰三角形边上

分析:  其实就是找给出的点在y轴上截距最大的时候,满足方程y=-x+b,移一下就是,x+y=b,只要找到x+y的最大值即可、

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 #include<cmath>
 5 using namespace std;
 6 int main()
 7 {
 8     int n;
 9     while(~scanf("%d",&n))
10     {
11         int a,b,ans=0;
12         while(n--)
13         {
14             scanf("%d %d",&a,&b);
15             ans=max(a+b,ans);
16         }
17         printf("%d\n",ans);
18     }
19     return 0;
20 }

 

1047B_Cover Points

标签:scan   cat   最小   prope   example   ica   三角形   printf   ret   

原文地址:https://www.cnblogs.com/LLLAIH/p/9736436.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!