B. Cover Points Codeforces Round #511 (Div. 2)数学

Posted dybala21

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了B. Cover Points Codeforces Round #511 (Div. 2)数学相关的知识,希望对你有一定的参考价值。

题目:

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 (1n10^5).

Each of the next nn lines contains two integers xixi and yiyi (1xi,yi10^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
", ans);
    }
    return 0;
}

  








以上是关于B. Cover Points Codeforces Round #511 (Div. 2)数学的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #523 (Div. 2) B. Views Matter

Educational Codeforces Round 55:B. Vova and Trophies

Codeforces Global Round 3 B. Born This Way

2018-2019 ACM-ICPC Brazil Subregional Programming Contest B. Marbles

Vertex cover reduces to set cover

理解小程序cover-view