CodeForces - 766B Mahmoud and a Triangle
【题意概述】
给定一串数,从中挑三个,判断能否组成一个有正面积的三角形,如果能就输出YES,否则就输出NO
【题目分析】
将 n 个数从大到小进行排列,三个三个往下去判断,只要后两个的和比第一个大的时候就满足条件。
【AC】
#include<bits/stdc++.h>
using namespace std; bool cmp(int a,int b) {
return a > b;
}
int main() {
int n;
int num[];
int ans = false;
while(~scanf("%d",&n)) {
ans = false;
for(int i = ; i < n; i++)
scanf("%d",&num[i]); sort(num,num+n,cmp); if(n >= )
for(int i = ; i < n-; i++)
if(num[i+]+num[i+] > num[i]) {
ans = true;
break;
} if(ans) printf("YES\n");
else printf("NO\n");
}
return ;
}
CodeForces - 766B Mahmoud and a Triangle的更多相关文章
- Codeforces Round #396 (Div. 2) B. Mahmoud and a Triangle 贪心
B. Mahmoud and a Triangle 题目连接: http://codeforces.com/contest/766/problem/B Description Mahmoud has ...
- Codeforces Round #396 (Div. 2) A - Mahmoud and Longest Uncommon Subsequence B - Mahmoud and a Triangle
地址:http://codeforces.com/contest/766/problem/A A题: A. Mahmoud and Longest Uncommon Subsequence time ...
- Codeforces766B Mahmoud and a Triangle 2017-02-21 13:47 113人阅读 评论(0) 收藏
B. Mahmoud and a Triangle time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- Codeforces 959D. Mahmoud and Ehab and another array construction task(构造, 简单数论)
Codeforces 959D. Mahmoud and Ehab and another array construction task 题意 构造一个任意两个数都互质的序列,使其字典序大等于a序列 ...
- 【codeforces 766B】Mahmoud and a Triangle
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Codeforces 766D. Mahmoud and a Dictionary 并查集 二元敌对关系 点拆分
D. Mahmoud and a Dictionary time limit per test:4 seconds memory limit per test:256 megabytes input: ...
- Codeforces 766D Mahmoud and a Dictionary 2017-02-21 14:03 107人阅读 评论(0) 收藏
D. Mahmoud and a Dictionary time limit per test 4 seconds memory limit per test 256 megabytes input ...
- Codeforces 862A Mahmoud and Ehab and the MEX
传送门:CF-862A A. Mahmoud and Ehab and the MEX time limit per test 2 seconds memory limit per test 256 ...
- Codeforces 959F Mahmoud and Ehab and yet another xor task 线性基 (看题解)
Mahmoud and Ehab and yet another xor task 存在的元素的方案数都是一样的, 啊, 我好菜啊. 离线之后用线性基取check存不存在,然后计算答案. #inclu ...
随机推荐
- jQuery ajax方法success()中后台传来的四种数据类型
1.后台返回一个页面 js代码 /**(1)用$("#content-wrapper").html(data);显示页面*/ $.ajax({ async : false, cac ...
- Kafka Cached zkVersion [62] not equal to that in zookeeper, skip updating ISR (kafka.cluster.Partition) 问题分析
我司业务Kafka集群是3节点(broker分别为10,20,30),每个Topic 3 Partition,3 Repilication的配置,早上起床突然发现所有Topic的Broker节点都变为 ...
- pandas.read_csv参数详解
读取CSV(逗号分割)文件到DataFrame 也支持文件的部分导入和选择迭代 更多帮助参见:http://pandas.pydata.org/pandas-docs/stable/io.html 参 ...
- QT生成随机数
QT生成随机数和C语言差距不大,C语言用srand()和rand(),QT是用Qsrand()和qrand(): QT生成随机数的格式是: qsrand(QTime(0,0,0).secsTo(QTi ...
- webpack全局安装
具体项目中才能使用webpack命令: npm install webpack -g npm install webpack-dev-server -g
- Leetcode 804. Unique Morse Code Words 莫尔斯电码重复问题
参考:https://blog.csdn.net/yuweiming70/article/details/79684433 题目描述: International Morse Code defines ...
- 双边滤波算法的简易实现bilateralFilter
没怎么看过双边滤波的具体思路,动手写一写,看看能不能突破一下. 最后,感觉算法还是要分开 水平 与 垂直 方向进行分别处理,才能把速度提上去. 没耐性写下去了,发上来,给大伙做个参考好了. 先上几张效 ...
- [POI 2004]ZAW
Description 在 Byte 山的山脚下有一个洞穴入口. 这个洞穴由复杂的洞室经过隧道连接构成. 洞穴的入口是 1 号点.两个洞室要么就通过隧道连接起来,要么就经过若干隧道间接的相连. 现在决 ...
- hihocoder 1419 重复旋律4
描述 小Hi平时的一大兴趣爱好就是演奏钢琴.我们知道一个音乐旋律被表示为长度为 N 的数构成的数列.小Hi在练习过很多曲子以后发现很多作品中的旋律有重复的部分. 我们把一段旋律称为(k,l)-重复的, ...
- P2515 [HAOI2010]软件安装
树形背包 #include<cstdio> #include<cstdlib> #include<algorithm> #include<cstring> ...