【题意概述】

   给定一串数,从中挑三个,判断能否组成一个有正面积的三角形,如果能就输出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. 百度资深架构师带你深入浅出一致性Hash原理

    一.前言 在解决分布式系统中负载均衡的问题时候可以使用Hash算法让固定的一部分请求落到同一台服务器上,这样每台服务器固定处理一部分请求(并维护这些请求的信息),起到负载均衡的作用. 但是普通的余数h ...

  2. SpringBoot(三):springboot启动参数

    springboot默认启动入口函数是支持接收参数,并且在整个应用程序内部也可以获取到这些参数,并且如果传递的参数是一些内部定义的参数将会被映射到springboot内部配置项,从而达到配置效果. s ...

  3. Spring Cloud学习笔记-003

    服务提供者:向注册中心注册服务 1. 新建maven工程,骨架选择quickstart,工程名称:demo-member 2. 加入相关依赖: 3. 编写服务接口: 4. 在src\main\reso ...

  4. vue2.0 带头冲锋(打包时,小心萝卜坑)

    距离上一期,时间间距可能有点长.谁让本人处于兴奋状态,生活已经不能自理. 哈哈哈,嗯,正经一下, 在已有的经验里总结一下那些容易抓狂的坑! 起因:npm run build 打包 本地运行,你以为可以 ...

  5. 【SQL.基础构建-第一节(1/4)】

    --        Tips:数据库与sql--    一.What's 数据库-- 1.数据库(Database,DB):将大量数据保存起来,通过计算机加工而成的可以进行高效访问的数据集合.--   ...

  6. 一、spring的成长之路——代理设计模式

    java常用的设计模式详解: 1.代理模式(JDK的动态代理) [IDept.java] ​ 这是一个简单的就接口,进行数据的更新 package com.itcloud.pattern.proxy; ...

  7. .NET Core2.0+MVC 用Redis/Memory+cookie实现的sso单点登录

    之前发布过使用session+cookie实现的单点登录,博主个人用的很不舒服,为什么呢,博主自己测试的时候,通过修改host的方法,在本机发布了三个站点,但是,经过测试,发现,三个站点使用的sess ...

  8. 11_Python的列表推导式_Python编程之路

    上一节我们结束了有关python的方法相关内容 这一节我们先来学习python的列表推导式 之前跟大家说过range方法的使用,在这里我就不做过多的解释了,如忘记了,请翻阅之前的介绍 列表推导式,是P ...

  9. 以太坊如何估计计算gas?

    以太坊如何估计估算计算gas?Etherscan上transaction info中有个gas used by txn,结果跟remix给的结果以及geth中getTransactionReceipt ...

  10. 实验吧_天下武功唯快不破&让我进去(哈希长度拓展攻击)

    天下武功唯快不破 第一反应就去抓包,看到返回包的header中有FLAG的值,base64解码后得到下图所示 这就要求我们在请求头中post相应key的值,我直接在burp中尝试了多次都没有用,想起来 ...