【codechef】Sereja and Votes(模拟)

65 篇文章 0 订阅
12 篇文章 0 订阅

Sereja conducted a voting about N of his opinions. Ai percent of people voted for opinion number i.
This statistics is called valid if sum of all Ai is equal to 100.

Now let us define rounding up of a statistics A.

  • If Ai is not an integer, it will be rounded up to next integer.
  • Otherwise it will be left as it is.

e.g. 4.1 became 54.9 became 5 but 6 will still be 6.

Now let us consider a statistics B of size N in which each of Bi is an integer. Now he wants to know whether there exists some valid statistic A of size N (may contain real numbers) such that after rounding it up, it becomes same as B?

Input

  • First line of input contain integer T - number of test cases.
  • For each test, case first line contains integer N - number of opinions.
  • Next line contains N integers B1, B2, ..., BN as defined in the problem.

Output

For each test case, output YES or NO denoting the answer of the problem, i.e. if there exists some statistics A which could be rounded to make it B, print YES otherwise NO.

Constraints

  • 1 ≤ T ≤ 50
  • 1 ≤ N ≤ 10000
  • 0 ≤ Bi ≤ 1000

Example

Input:
3
3
30 30 30
4
25 25 25 25
2
50 51
Output:
NO
YES
YES

Explanation

  • In test case 1, There can not be any A which could be rounded up to get B. Hence answer is NO.
  • In test case 2, In this case A = {25, 25, 25, 25}. After rounding we get {25, 25, 25, 25} which is equal to B. Hence answer is YES.
  • In test case 3, A = {49.5, 50.5}. After rounding up we get {50, 51} which is equal to B. Hence answer is YES.

比例是四舍五入的,总比例为100,看这些比例构成是否符合条件
#include<iostream>  
#include<algorithm>  
#include<string>  
#include<map>  
#include<set>  
#include<cmath>  
#include<vector>
#include<queue>
#include<string.h>  
#include<stdlib.h>  
#include<cstdio>  
#define ll long long  
using namespace std; 
int main(){
    int t;  
    scanf("%d",&t); 
    while(t--){ 
		int n,a;
		cin>>n;
		int s1=0,s2=0,s=0;  //s1:上界 s2:下界  
		for(int i=0;i<n;++i){
			cin>>a;
			s1+=a;
			if(a>0)
				s2+=a-1;
			else{
				s2+=a;
				s++;
			}
		}	
		if(100>=s2&&100<=s1&&s1<100+n-s) //最后一个条件不要漏掉 
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
    }  
    return 0;     
} 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
em指的是"电子邮件",是电子邮件的缩写。 随着互联网的发展,电子邮件已经成为了人们日常生活中不可或缺的一部分。通过电子邮件,我们可以方便快捷地与世界各地的人进行沟通和交流。 首先,em的便利性是其最大的特点之一。只需轻轻一点,你就可以向对方发送电子邮件。与传统的信函相比,电子邮件的传送速度更快,几乎可以瞬间到达对方的邮箱。而且,相比打电话或者视频通话,电子邮件可以让人们在不同的时区和地域进行随时互动,无论是商务沟通还是与亲朋好友聊天都变得更加便捷。 其次,em的存储性也是不可忽视的优点。相比传统的纸质信件,电子邮件可以永久保留在电脑或者云端中。这意味着,我们可以随时随地地查看和回顾电子邮件内容,方便我们整理和管理个人或者工作相关资料。另外,电子邮件还能够附带发送图片、文件等附件,极大地方便了信息的传递和共享。 最后,em的私密性也是人们选择使用电子邮件的原因之一。通过合适的加密和密码保护措施,我们可以确保电子邮件内容的安全性和隐私性。这使得电子邮件成为了商务合作和个人隐私传递的首选方式。 总而言之,em的发展使得人们的沟通变得更加迅捷、方便和高效。无论是在工作还是生活中,em都成为了不可或缺的一部分,大大提高了我们的生活质量和效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值