-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharraywithoddsum.cpp
More file actions
53 lines (52 loc) · 878 Bytes
/
arraywithoddsum.cpp
File metadata and controls
53 lines (52 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include<bits/stdc++.h>
using namespace std;
// https://codeforces.com/contest/1296/problem/A
bool isSumOdd(int arr[],int n)
{
int sum=0;
for(int i=0;i<n;i++)
{
sum+=arr[i];
}
if(sum%2==0)
{
return false;
}
return true;
}
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int arr[n];
int odd=0,even=0;
for(int i=0;i<n;i++)
{
cin>>arr[i];
if(arr[i]%2!=0)
{
odd++;
}
else
{
even++;
}
}
if(isSumOdd(arr,n))
{
cout<<"YES"<<endl;
continue;
}
if(odd==0 or even==0)
{
cout<<"NO"<<endl;
continue;
}
cout<<"YES"<<endl;
}
return 0;
}