【CodeForces - 1047B 】Cover Points (数学,构造,思维)
題干:
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
3 1 1 1 2 2 1Output
3Input
4 1 1 1 2 2 1 2 2Output
4Note
Illustration for the first example:?
Illustration for the second example:?
解題報告:
? ? 這題比較巧妙的一個地方在于,要求次短邊的最小長度,其實也就是最長直角邊的最短長度(因為斜邊肯定最長)。所以既然要最短,那么等腰直角三角形,所以,,看代碼就理解了。
AC代碼:
#include<bits/stdc++.h> #define ll long long using namespace std;int main() {int n;cin>>n;ll ans = -1;int a,b;for(int i = 1; i<=n; i++) {scanf("%d%d",&a,&b);ans = max(ans,(ll)a+b);}cout << ans << endl;return 0; }?
總結
以上是生活随笔為你收集整理的【CodeForces - 1047B 】Cover Points (数学,构造,思维)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 打击网络黑公关!比亚迪悬赏500万 吉利
- 下一篇: 【POJ - 2823】 Sliding