Codeforces 1363A - Odd Selection Solution

  Solution in C++: 

///******Bismillahir-Rahmanir-Rahim******///

///AH Tonmoy

///Department of CSE,23rd batch

///Islamic University,Bangladesh 

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t;
  6. cin>>t;
  7. while(t--)
  8. {
  9. int n,i,c,a,e=0,o=0,in;
  10. cin>>n>>c;
  11. for( i=0; i<n; i++)
  12. {
  13. cin>>in;
  14. if(in%2==0)
  15. e++;
  16. else
  17. o++;
  18. }
  19. if(o==0||(e==0&&c%2==0)||(n==c&&o%2==0))
  20. cout<<"no"<<endl;
  21. else
  22. cout<<"yes"<<endl;
  23. }
  24. }

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.