CodeForces 766B Mahmoud and a Triangle
来源:互联网 发布:安卓开发艺术探索源码 编辑:程序博客网 时间:2024/05/22 08:20
题目链接:http://codeforces.com/contest/766/problem/B
题意:给你n条木棍,问你能不能选三根组成三角形
解析:排个序,扫一遍,判断两边之和大于第三边即可
#include <iostream>#include <cstdio>#include <algorithm>#include <vector>#include <cstring>#include <queue>using namespace std;const int maxn = 1e6+100;const int inf = 0x7fffffff;int a[maxn];int main(void){ int n; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); int flag = 0; for(int i=2;i<n;i++) { if(a[i]<a[i-1]+a[i-2]) { flag = 1; break; } } if(flag) puts("YES"); else puts("NO"); return 0;}
0 0
- 【codeforces 766B】Mahmoud and a Triangle
- codeforces 766B Mahmoud and a Triangle
- CodeForces - 766B Mahmoud and a Triangle
- codeforces 766 B Mahmoud and a Triangle
- Codeforces 766B-Mahmoud and a Triangle
- CodeForces 766B Mahmoud and a Triangle
- codeforces 766B Mahmoud and a Triangle
- CodeFroces 766B Mahmoud and a Triangle
- 766B Mahmoud and a Triangle
- 766B-Mahmoud and a Triangle
- Mahmoud and a Triangle (CodeForces
- B. Mahmoud and a Triangle
- Codeforces Mahmoud and a Triangle (水
- Mahmoud and a Triangle 【codeforces】 【水题】
- #396 B. Mahmoud and a Triangle
- Mahmoud and a Triangle
- Codeforces Round #396(Div. 2)B. Mahmoud and a Triangle【上古时代题】nlogn判断三角形
- Codeforces Round #396 (Div. 2) B. Mahmoud and a Triangle 贪心
- matlab 排列组合函数
- mysql oracle 分页
- [leetcode] 406. Queue Reconstruction by Height -- JavaScript 代码
- SpringMVC-14 运行流程详解
- 言语之间智能交互,物联智慧如“影”随形 — 机智云带你探秘Amazon Alexa与AWS IoT | 4月11日 深圳
- CodeForces 766B Mahmoud and a Triangle
- 工具网站
- 初学者svn项目发布和下载和如果项目不全
- swift学习一月总结
- bootstrap modal模态窗口拖拽功能
- 【Tomcat】Filter 原理
- 最全面的RecyclerView源码解析(一)
- 第90篇一对多之学生举手提问及老师点课堂模式掉线
- Unity 光标控制进度条Slider