当前位置:网站首页>1146: eat candy
1146: eat candy
2022-04-21 09:10:00 【Qian Qian】
1146: Eat candy
Title Description
HOHO, Finally from Speakless I won all the candy in my hand , yes Gardon There is a special hobby when eating candy , I just don't like eating the same candy twice in a row , I like to eat one first A All kinds of candy , Another taste next time , Take one B All kinds of candy , such ; But Gardon I don't know if there's a sort of order in which he can eat all the candy ? Please write a program to help calculate .
Input
The first line has an integer T, Next T Group data , The percentage of data in each group 2 That's ok , The first line is an integer N(0 < N <= 1000000), Indicates the type of candy . The second line is N Number , Indicates the number of each kind of candy Mi(0 < Mi <= 109).
Output
For each set of data , Output one line , Contains a "Yes" perhaps "No".
The sample input Copy
2
3
4 1 1
5
5 4 3 2 1
Sample output Copy
No
Yes
source / classification
#include<stdio.h>
#include<string.h>
#define N 1000
/* Eat candy Two adjacent flavors cannot be repeated Find the most , The rest and +1<=max max>sum-max+1 When output no */
int main(){
int t,n,k,sum=0,max=0;
scanf("%d",&t);
while(t--){
max=sum=0;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&k);
sum+=k;
if(k>max) max=k;
}
if(2*max-1>sum) printf("No\n");
else printf("Yes\n");
}
return 0;
}
版权声明
本文为[Qian Qian]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210906132341.html
边栏推荐
- 模拟实现vector
- ShardingSphere简介
- BUUCTF[ACTF2020 新生赛]Include
- 2022 chemical automation control instrument examination exercises and simulation examination
- 基于Ansible实现Apache Doris快速部署运维指南
- Ue5 little knowledge point animation blueprint interface cannot copy new in editor
- ue5 小知识点 动画蓝图接口 不能在editor中复制新的
- Controlled and uncontrolled components
- 1166: 实数取整(指针专题)
- ACTF2020 新生赛 Upload 1
猜你喜欢

Convolution operation and cross correlation operation
Open3d reads and writes ply point cloud files

Flink's API introduction case

Drafting and Revision: Laplacian Pyramid Network for Fast High-Quality Artistic Style Transfer--T Li

CC00000.CloudJenkins—————————————

C language counting and sorting

Note 0104 MySQL advanced - index - Overview

2022年流动式起重机司机考试练习题模拟考试平台操作

目标检测入门常见问题(深度学习 / 图像分类)

Pipy MQTT 代理之(三)Logging
随机推荐
YApi基本使用(2022-04-15)
2022 mobile crane driver examination exercises simulated examination platform operation
1153: 简易版最长序列
Grid division [DFS]
1149: 组合三位数之二
2022年上海市安全员C证考试模拟100题及模拟考试
Handler异步消息传递机制(一)Handler常用基本用法
ue5 小知识点 动画蓝图接口 不能在editor中复制新的
【ACM】131. Split palindrome string
BUUCTF[HCTF 2018]WarmUp
C#100分秘籍 sduwh
About shardingsphere
Major programming languages and applications in 2022
1163: 亲和串(字符串)
我的博客导航目录(持续整理更新中。。。)
uniapp 热更新和整包更新
CC00019.CloudJenkins—————————————
基于Ansible实现Apache Doris快速部署运维指南
BUUCTF[HCTF 2018]WarmUp
Uniapp hot update and full package update