【题意概述】

   给定一串数,从中挑三个,判断能否组成一个有正面积的三角形,如果能就输出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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. Codeforces 959D. Mahmoud and Ehab and another array construction task(构造, 简单数论)

    Codeforces 959D. Mahmoud and Ehab and another array construction task 题意 构造一个任意两个数都互质的序列,使其字典序大等于a序列 ...

  5. 【codeforces 766B】Mahmoud and a Triangle

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. Codeforces 766D. Mahmoud and a Dictionary 并查集 二元敌对关系 点拆分

    D. Mahmoud and a Dictionary time limit per test:4 seconds memory limit per test:256 megabytes input: ...

  7. 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 ...

  8. 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 ...

  9. Codeforces 959F Mahmoud and Ehab and yet another xor task 线性基 (看题解)

    Mahmoud and Ehab and yet another xor task 存在的元素的方案数都是一样的, 啊, 我好菜啊. 离线之后用线性基取check存不存在,然后计算答案. #inclu ...

随机推荐

  1. 安装shellinabox-master

    安装shellinabox-master 1 插件介绍:通过web页面管理linux主机(电脑版) a. 安装 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ...

  2. cache和buffer

    一.free命令是Linux查看内存使用情况的命令 1. centos 7风格 [root@bogon init.d]# free -m total used free shared buff/cac ...

  3. 1.1 WEB API 在帮助文档页面进行测试

    这篇文章http://www.cnblogs.com/landeanfen/p/5210356.html写得比较详细, 我就挑简单的来说. 首先用这功能要在WEB API创建的帮助文档下面,如果你使用 ...

  4. property()函数

    class C: def __init__(self, size=10): self.size = size def getXSize(self): return self.size def setX ...

  5. 原生js中实现全选和反选功能

    <!DOCTYPE html>      <html>      <head lang="en">          <meta char ...

  6. angularjs中的run()方法使用

    run方法用于初始化全局的数据,仅对全局作用域起作用. 举个栗子吧:<script type="text/javascript"> var m1 = angular.m ...

  7. jacascript 判断元素尺寸和位置

    前言:这是笔者学习之后自己的理解与整理.如果有错误或者疑问的地方,请大家指正,我会持续更新! getBoundingClientRect() 判断一个元素的尺寸和位置是简单的方法就是使用 obj.ge ...

  8. dev gridControl 自定义绘制列头颜色

    1.添加事件CustomDrawColumnHeader private void gvw1_CustomDrawColumnHeader(object sender, DevExpress.Xtra ...

  9. mysql乱码配置

    1.进入mysql   show variables like "char%"   2.在/etc/mysql/my.cnf中增加以下内容   [client] default-c ...

  10. [LeetCode] Can Place Flowers 可以放置花

    Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, ...