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.
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).
Print the minimum length of the shorter side of the triangle. It can be proved that it's always an integer.
3
1 1
1 2
2 1
3
4
1 1
1 2
2 1
2 2
4
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)【数学】的更多相关文章
- Codeforces Round #511 (Div. 2)
Codeforces Round #511 (Div. 2) #include <bits/stdc++.h> using namespace std; int n; int main() ...
- 2018.9.21 Codeforces Round #511(Div.2)
只写了AB,甚至还WA了一次A题,暴露了蒟蒻的本质=.= 感觉考的时候有好多正确或和正解有关的思路,但是就想不出具体的解法或者想的不够深(长)(怕不是过于鶸) 话说CF的E题怎么都这么清奇=.= A. ...
- Codeforces Round #511 (Div. 2):C. Enlarge GCD(数学)
C. Enlarge GCD 题目链接:https://codeforces.com/contest/1047/problem/C 题意: 给出n个数,然后你可以移除一些数.现在要求你移除最少的数,让 ...
- Codeforces Round #511 (Div. 2)-C - Enlarge GCD (素数筛)
传送门:http://codeforces.com/contest/1047/problem/C 题意: 给定n个数,问最少要去掉几个数,使得剩下的数gcd 大于原来n个数的gcd值. 思路: 自己一 ...
- Codeforces Round #511 (Div. 1) C. Region Separation(dp + 数论)
题意 一棵 \(n\) 个点的树,每个点有权值 \(a_i\) .你想砍树. 你可以砍任意次,每次你选择一些边断开,需要满足砍完后每个连通块的权值和是相等的.求有多少种砍树方案. \(n \le 10 ...
- Codeforces Round #511 Div.1 A Div.2 C
嗯切一题走人很开心. gzy-50分比我还惨. 题意:有n个数,去掉尽量少的数使得剩下数的gcd变大. 首先把这n个数都除以gcd,就变成了去掉尽量少的数使得gcd不等于1. 可以枚举一个质数,然后统 ...
- 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 ...
- 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 ...
- Codeforces Round #511 (Div. 2) C. Enlarge GCD
题目链接 题目就是找每个数的最小素因子,然后递归除,本来没啥问题,结果今天又学习了个新坑点. 我交了题后,疯狂CE,我以为爆内存,结果是,我对全局数组赋值, 如果直接赋值,会直接在exe内产生内存,否 ...
随机推荐
- instanceof php
instdnceof php5 的一个新成员 功能: 使用这个关键字可以确定一个对象是否是类的实例,是否是累的子类 ,还是实现了某个特定的接口. <?php class A{} class B ...
- Java-Http
1 import java.io.BufferedReader; 2 import java.io.BufferedWriter; 3 import java.io.IOException; 4 im ...
- solr第二天 京东案例
一.案例 电商网站的搜索 在互联网项目中做搜索都应该使用全文检索. 查询的是索引库,搜索功能跟数据库没有关系.实现分析: 1.先创建索引库 需要把数据库中的数据导入到索引库中. 需要把数据库中每个字段 ...
- while 和do while循环的区别
int a; scanf_s("%d",&a); while(a>0) { //do something; } while循环先要判断条件是否成立,如果不成立,那么就 ...
- 怎样去阅读一份php源代码
一份好的源代码例如 dz的论坛,wind论坛,帝国cms,dedecms等,都具有自己的一套设计思路和设计模式,所以在看某个产品之前就要做好心理准备,可以把自己的经验和这些产品做对比,但千万别一直用自 ...
- 简单的Session案例 —— 一次性验证码
一次性验证码的主要目的就是为了限制人们利用工具软件来暴力猜测密码,其原理与利用Session防止表单重复提交的原理基本一样,只是将表单标识号变成了验证码的形式,并且要求用户将提示的验证码手工填写进一个 ...
- 跨域问题hbuilder
1.借助jquery-jsonp插件 $.jsonp({ url: url, data: { 'name': usd, 'passwd': pass }, callbackParameter: &qu ...
- C++中的Trivial 、POD、non-POD和Standard Layout概念
POD types non-POD types Standard Layout types A Formal Definition Informally, a standard layout clas ...
- 什么是Condition Number(条件数)?
In the field of numerical analysis, the condition number of a function with respect to an argument m ...
- 查询某张表被哪些存储过程或者视图用到的sql语句
/*查询某张表被哪些存储过程或者视图用到的sql语句*/select distinct object_name(id) from syscomments where id in (select id ...