30 lines
702 B
Java
30 lines
702 B
Java
package LanQiaoOJ;
|
||
|
||
import java.util.Scanner;
|
||
|
||
/*小蓝吃糖果
|
||
* 题目描述
|
||
小蓝有 n 种糖果,每种数量已知。小蓝不喜欢连续 2次吃同样的糖果。问有没有可行的吃糖方案。
|
||
输入描述
|
||
第一行是整数 n(0<n<1000000)。
|
||
第二行包含 n 个数,表示 n 种糖果的数量mi,0<mi<1000000。
|
||
输出描述
|
||
输出一行,包含一个 Yes 或 no。 */
|
||
public class 小蓝吃糖果 {
|
||
public static void main(String[] args) {
|
||
Scanner sc= new Scanner(System.in);
|
||
int n=sc.nextInt();//1e6
|
||
//ans表示统计所有的糖果数量
|
||
long ans=0;
|
||
//统计最大糖果数量
|
||
int max=0;
|
||
for(int i=0;i<n;i++) {
|
||
int x=sc.nextInt();
|
||
ans=ans+x;
|
||
max=Math.max(x, max);
|
||
}
|
||
//L表示long类型
|
||
System.out.print(max*2L>ans?"No":"Yes");
|
||
}
|
||
}
|