# Sereja and Votes | CodeChef Solution

Hello coders, today we are going to solve Sereja and Votes CodeChef Solution whose Problem Code is SEAVOTE.

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 Format

• 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 Format

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

• Subtask #1:Â N â‰¤ 100Â (50 points)
• Subtask #2:Â originalÂ (50 points)

Example

Sample Input

``````3
3
30 30 30
4
25 25 25 25
2
50 51``````

Sample Output

``````NO
YES
YES``````

## Solution – Sereja and Votes

### C++

```#include<bits/stdc++.h>
using namespace std;
int main()
{
int t, n, s, a, x;
scanf("%d",&t);
while(t--)
{
scanf("%d", &n);
s = 0;
x = 100;
for(int i = 0; i < n; i++)
{
scanf("%d", &a);
s += a;
if(a) x++;
}
if(s >= 100 && s < x) printf("YES\n");
else printf("NO\n");
}
return 0;
}```

### Python

```T = int(input())
for _ in range(T):
B = []
N = int(input())
B = list(map(int, input().split()))

suma = 0
valid = True
count = 0

for i in B:
if i > 100:
valid = False
if i > 0:
count += 1
suma = sum(B)

if (valid and (suma -100 >=0) and (suma - 100 < count)):
print('YES')
else:
print('NO')```

### Java

```/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
StringBuilder sb = new StringBuilder();
while(t-- > 0) {
int count = 0;
int zeros= 0;
for(int i=0; i<n; i++) {
count += Integer.parseInt(per[i]);
if(Integer.parseInt(per[i]) == 0) {
zeros++;
}
}

int num = n - zeros;

if(count < 100 + num && count >= 100) {
sb.append("YES\n");
} else {
sb.append("NO\n");
}
}
System.out.print(sb.toString());
}
}
```

Disclaimer: The above Problem (Sereja and Votes) is generated by CodeChef but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.