B. Mahmoud and a Triangle1000 / 数学

Posted 幽殇默

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了B. Mahmoud and a Triangle1000 / 数学 相关的知识,希望对你有一定的参考价值。


https://codeforces.com/problemset/problem/766/B
就是问有没有三条边可以构成三角形。

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int a[N],n;
bool check(int a,int b,int c)
{
	if(a+b<=c) return false;
	if(a+c<=b) return false;
	if(b+c<=a) return false;
	return true;
}
int main(void)
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for(int i=2;i<=n;i++)
	{
		if(check(a[i-2],a[i-1],a[i])) 
		{
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

以上是关于B. Mahmoud and a Triangle1000 / 数学 的主要内容,如果未能解决你的问题,请参考以下文章

codeforces 862B B. Mahmoud and Ehab and the bipartiteness

Mahmoud and a Dictionary

Codeforces 862B - Mahmoud and Ehab and the bipartiteness

CF766D Mahmoud and a Dictionary

CF766D Mahmoud and a Dictionary

Codeforces Round #396 (Div. 2) C. Mahmoud and a Message DP