题目:

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≤10^5).

Each of the next nn lines contains two integers xixi and yiyi (1≤xi,yi≤10^9).

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:

题意分析:

在二维平面坐标系,给你N个坐标点(都在第一象限),让你找一条直线,使这条直线能够与两条坐标轴围成一个等腰三角形,这个三角形能包含所有的点。求这个三角形最短的边长。

边长最短,肯定就是这些点中最外层的点刚好在直线上即可。因为是等腰三角形,所以斜率必然为-1。那么这条直线的表达式为:X+Y= d; 那么所有的点满足X+Y <= d。

这个d的最小值就是我们所要求的,转换一下,相当于就是求输入坐标的x+y的最大值。

代码:

#include <iostream>
#include <cstdio>
using namespace std; int Max(const int a, const int b)
{
return a>b?a:b;
} int main()
{
int N, a, b, ans = 0;
while(~scanf("%d", &N))
{
for(int i = 0; i < N; i++)
{
scanf("%d %d", &a, &b);
ans = Max(ans, a+b);
}
printf("%d\n", ans);
}
return 0;
}

  

B. Cover Points Codeforces Round #511 (Div. 2)【数学】的更多相关文章

  1. Codeforces Round #511 (Div. 2)

    Codeforces Round #511 (Div. 2) #include <bits/stdc++.h> using namespace std; int n; int main() ...

  2. 2018.9.21 Codeforces Round #511(Div.2)

    只写了AB,甚至还WA了一次A题,暴露了蒟蒻的本质=.= 感觉考的时候有好多正确或和正解有关的思路,但是就想不出具体的解法或者想的不够深(长)(怕不是过于鶸) 话说CF的E题怎么都这么清奇=.= A. ...

  3. Codeforces Round #511 (Div. 2):C. Enlarge GCD(数学)

    C. Enlarge GCD 题目链接:https://codeforces.com/contest/1047/problem/C 题意: 给出n个数,然后你可以移除一些数.现在要求你移除最少的数,让 ...

  4. Codeforces Round #511 (Div. 2)-C - Enlarge GCD (素数筛)

    传送门:http://codeforces.com/contest/1047/problem/C 题意: 给定n个数,问最少要去掉几个数,使得剩下的数gcd 大于原来n个数的gcd值. 思路: 自己一 ...

  5. Codeforces Round #511 (Div. 1) C. Region Separation(dp + 数论)

    题意 一棵 \(n\) 个点的树,每个点有权值 \(a_i\) .你想砍树. 你可以砍任意次,每次你选择一些边断开,需要满足砍完后每个连通块的权值和是相等的.求有多少种砍树方案. \(n \le 10 ...

  6. Codeforces Round #511 Div.1 A Div.2 C

    嗯切一题走人很开心. gzy-50分比我还惨. 题意:有n个数,去掉尽量少的数使得剩下数的gcd变大. 首先把这n个数都除以gcd,就变成了去掉尽量少的数使得gcd不等于1. 可以枚举一个质数,然后统 ...

  7. C. Enlarge GCD Codeforces Round #511 (Div. 2)【数学】

    题目: Mr. F has nn positive integers, a1,a2,…,an. He thinks the greatest common divisor of these integ ...

  8. A. Little C Loves 3 I Codeforces Round #511 (Div. 2) 【数学】

    题目: Little C loves number «3» very much. He loves all things about it. Now he has a positive integer ...

  9. Codeforces Round #511 (Div. 2) C. Enlarge GCD

    题目链接 题目就是找每个数的最小素因子,然后递归除,本来没啥问题,结果今天又学习了个新坑点. 我交了题后,疯狂CE,我以为爆内存,结果是,我对全局数组赋值, 如果直接赋值,会直接在exe内产生内存,否 ...

随机推荐

  1. Base -快捷键|通配符|特殊符号|输出(正确与错误的保存)

    curl + a   移动光标到行首. curl +e    移动光标到行尾. curl +k    剪切光标所在位置到行末的字符. curl+u    剪切光标所在位置到行首的字符. curl +y ...

  2. 2-python代码坑点

    #切片: # L = ['aaa', 'bbb', 'ccc', 'ddd'] # print(L[1 : 3]) #取[1, 3):下标 # L = list(range(100)) # print ...

  3. Solidity oraclize query apikey加密

    solidity 程序中如果用到oraclize query,api调用需要apikey,则最好加密apikey,否则公开solidity代码时会连同apikey一起公开. 加密方法: https:/ ...

  4. Django框架 之 Form表单和Ajax上传文件

    Django框架 之 Form表单和Ajax上传文件 浏览目录 Form表单上传文件 Ajax上传文件 伪造Ajax上传文件 Form表单上传文件 html 1 2 3 4 5 6 7 <h3& ...

  5. Flask框架 之 路由和视图详解

    路由+视图 我们之前了解了路由系统是由带参数的装饰器完成的. 路由本质:装饰器和闭包实现的. 路由设置的两种方式 来看个例子. @app.route('/index') def index(): re ...

  6. 一、office web apps 部署

    原文出处:http://www.cnblogs.com/yanweidie/p/4516164.html 原文出处:https://www.cnblogs.com/poissonnotes/p/323 ...

  7. The Difference Between @Helpers and @Functions In WebMatrix

    from: http://www.mikesdotnetting.com/article/173/the-difference-between-helpers-and-functions-in-web ...

  8. css3的那些高级选择器一

    css大家都不陌生了,从1996年12月css1正式推出,经历了1998年5月css2,再到2004年2月css2.1,最后一直到2010年推出的css3.css的推出给web带来巨大 的改变,使我们 ...

  9. 设计模式07: Bridge 桥接模式(结构型模式)

    Bridge 桥接模式(结构型模式) 抽象与实现 抽象不应该依赖于实现细节,实现细节应该依赖于抽象. 抽象B稳定,实现细节b变化 问题在于如果抽象B由于固有的原因,本身并不稳定,也有可能变化,怎么办? ...

  10. 20169219 实验一 Java开发环境的熟悉(Linux + IDEA)

    实验内容 1.使用JDK编译.运行简单的Java程序: 2.使用IDEA 编辑.编译.运行.调试Java程序. 如条件断点设置:我们在第14行左边断点处单击鼠标右键,弹出断点属性框,我们设置条件&qu ...