303365: CF653A. Bear and Three Balls
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Bear and Three Balls
题意翻译
Limak是一只小北极熊。他有N个球,我的第i个球的大小是T[i]。 Limak想给他的三个朋友每人一个球。 但是赠送礼物并不容易——莱马克必须遵守两条规则才能使朋友快乐: 没有两个朋友能得到同样大小的球。 没有两个朋友能得到大小超过2个2的球。 例如,Limak可以选择大小为4,5和3的球,或者大小为90,91和92的球。但他不能选择大小为5,5和6的球(两个朋友会得到同样大小的球),他不能选择大小为 30,31和33的球(因为尺寸30和33相差超过2)。 你的任务是检查Limak是否可以选择满足以上条件的三个球。 感谢@something 提供的翻译题目描述
Limak is a little polar bear. He has $ n $ balls, the $ i $ -th ball has size $ t_{i} $ . Limak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make friends happy: - No two friends can get balls of the same size. - No two friends can get balls of sizes that differ by more than $ 2 $ . For example, Limak can choose balls with sizes $ 4 $ , $ 5 $ and $ 3 $ , or balls with sizes $ 90 $ , $ 91 $ and $ 92 $ . But he can't choose balls with sizes $ 5 $ , $ 5 $ and $ 6 $ (two friends would get balls of the same size), and he can't choose balls with sizes $ 30 $ , $ 31 $ and $ 33 $ (because sizes $ 30 $ and $ 33 $ differ by more than $ 2 $ ). Your task is to check whether Limak can choose three balls that satisfy conditions above.输入输出格式
输入格式
The first line of the input contains one integer $ n $ ( $ 3<=n<=50 $ ) — the number of balls Limak has. The second line contains $ n $ integers $ t_{1},t_{2},...,t_{n} $ ( $ 1<=t_{i}<=1000 $ ) where $ t_{i} $ denotes the size of the $ i $ -th ball.
输出格式
Print "YES" (without quotes) if Limak can choose three balls of distinct sizes, such that any two of them differ by no more than $ 2 $ . Otherwise, print "NO" (without quotes).
输入输出样例
输入样例 #1
4
18 55 16 17
输出样例 #1
YES
输入样例 #2
6
40 41 43 44 44 44
输出样例 #2
NO
输入样例 #3
8
5 972 3 4 1 4 970 971
输出样例 #3
YES