ACM ICPC 2017 Warmup Contest 9 L
L. Sticky Situation
While on summer camp, you are playing a game of hide-and-seek in the forest. You need to designate a “safe zone”, where, if the players manage to sneak there without being detected,they beat the seeker. It is therefore of utmost importance that this zone is well-chosen.
You point towards a tree as a suggestion, but your fellow hide-and-seekers are not satisfied. After all, the tree has branches stretching far and wide, and it will be difficult to determine whether a player has reached the safe zone. They want a very specific demarcation for the safe zone. So, you tell them to go and find some sticks, of which you will use three to mark anon-degenerate triangle (i.e. with strictly positive area) next to the tree which will count as the safe zone. After a while they return with a variety of sticks, but you are unsure whether you can actually form a triangle with the available sticks.
Can you write a program that determines whether you can make a triangle with exactly three of the collected sticks?
Input
The first line contains a single integer N , with 3 ≤ N ≤ 20 000, the number of sticks collected. Then follows one line with Npositive integers, each less than 2^{60}260, the lengths of the sticks which your fellow campers have collected.
Output
Output a single line containing a single word: possible if you can make a non-degenerate triangle with three sticks of the provided lengths, and impossible if you can not.
样例输入1
3
1 1 1
样例输出1
possible
样例输入2
5
3 1 10 5 15
样例输出2
impossible
题目来源
ACM ICPC 2017 Warmup Contest 9
问数组中是否存在3个数组成三角形。
//2017-10-24
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long using namespace std; const int N = ;
ll arr[N];
int n; int main()
{
while(~scanf("%d", &n)){
for(int i = ; i < n; i++)
scanf("%lld", &arr[i]);
sort(arr, arr+n);
bool ok = false;
for(int i = ; i < n-; i++)
if(arr[i] + arr[i+] > arr[i+]){
ok = true;
break;
}
if(ok)printf("possible\n");
else printf("impossible\n");
} return ;
}
ACM ICPC 2017 Warmup Contest 9 L的更多相关文章
- ACM ICPC 2017 Warmup Contest 9 I
I. Older Brother Your older brother is an amateur mathematician with lots of experience. However, hi ...
- ACM ICPC 2017 Warmup Contest 1 D
Daydreaming Stockbroker Gina Reed, the famous stockbroker, is having a slow day at work, and between ...
- 训练报告 (2014-2015) 2014, Samara SAU ACM ICPC Quarterfinal Qualification Contest
Solved A Gym 100488A Yet Another Goat in the Garden B Gym 100488B Impossible to Guess Solved C Gym ...
- 2015-2016 ACM ICPC Baltic Selection Contest
这是上礼拜三的训练赛,以前做过一次,这次仅剩B题没补.题目链接:https://vjudge.net/contest/153192#overview. A题,水题. C题,树形DP,其实是一个贪心问题 ...
- 2015-2016 ACM ICPC Baltic Selection Contest D - Journey(广搜)
- 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest
2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest A - Arranging Wine 题目描述:有\(R\)个红箱和\(W\)个白箱,将这 ...
- hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4706 Children's Day Time Limit: 2000/1000 MS (Java/Others) ...
- ACM ICPC Kharagpur Regional 2017
ACM ICPC Kharagpur Regional 2017 A - Science Fair 题目描述:给定一个有\(n\)个点,\(m\)条无向边的图,其中某两个点记为\(S, T\),另外标 ...
- 2017 ACM ICPC Asia Regional - Daejeon
2017 ACM ICPC Asia Regional - Daejeon Problem A Broadcast Stations 题目描述:给出一棵树,每一个点有一个辐射距离\(p_i\)(待确定 ...
随机推荐
- 漏洞利用教程:msfpayload 和 Backdooring EXEs
漏洞利用教程:msfpayload 和 Backdooring EXEs 此版本的PrimalSec漏洞教程系列将介绍如何使用msfpayload创建各种有效负载.msfpayload是Metaspl ...
- Retrofit官方文档翻译
Retrofit官方文档翻译 官方文档网址 http://square.github.io/retrofit/ 介绍 Retrofit 将你的 HTTP API 转换为 Java 接口. public ...
- 微信小程序合法域名配置-不校验合法域名、web-view(业务域名)、TLS 版本以及 HTTPS 证书
微信小程序合法域名配置-不校验合法域名.web-view(业务域名).TLS 版本以及 HTTPS 证书 很多教程说按照以上方式调用即可.但是当我们在程序中实际调用以上程序时,就会报错, http:/ ...
- 1 分钟教会你用 Spring Boot 发邮件
Spring Boot 提供了一个发送邮件的简单抽象,使用的是下面这个接口. org.springframework.mail.javamail.JavaMailSender Spring Boot ...
- 【jdbc】连接数据库从浅入深
一.回想 还记得以前自学的时候,刚接触到数据库,讲解的连接数据库的最基本的理论知识和方法,现在温习一下基础知识并总结如下! 1.JDBC连接数据库的基本流程 加载JDBC驱动程序 —> 提供JD ...
- Asp.Net Core Web Api图片上传(一)集成MongoDB存储实例教程
Asp.Net Core Web Api图片上传及MongoDB存储实例教程(一) 图片或者文件上传相信大家在开发中应该都会用到吧,有的时候还要对图片生成缩略图.那么如何在Asp.Net Core W ...
- VueJs(11)---vue-router(命名路由,命名视图,重定向别名,路由组件传参)
vue-router 上篇文章讲了第一篇vue-router相关文章,文章地址:VueJs(10)---vue-router(进阶1) 一.命名路由 有时候,通过一个名称来标识一个路由显得更方便一些, ...
- 【jQuery】(4)---jQuery常用事件
[jQuery入门](4)---jQuery常用事件 一.常用事件列表 1.blur() 当失去焦点时触发.包括鼠标点击离开和TAB键离开. 2.change() 当元素获取焦点后,值改变失去焦点事触 ...
- hibernate框架(3)---持久化对象
持久化对象 再讲持久化对象之前,我们先来理解有关session中get方法与 load方法区别: 简单总结: (1)如果你使用load方法,hibernate认为该id对应的对象(数据库记录)在数据库 ...
- mysql常用字符串操作函数大全,以及实例
今天在论坛中看到一个关于mysql的问题,问题如下 good_id cat_id12654 665,56912655 601,4722 goods_id是商品i ...