fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int n; cin >> n;
  5. vector<int> c,l;
  6. for(int i = 0 ; i < n ; i++){
  7. int x; cin >> x;
  8. if(x % 2 ==0){
  9. c.push_back(x);
  10. }
  11. else{
  12. l.push_back(x);
  13. }
  14. }
  15. if(c.size() % 2 == 0){
  16. cout << "YES";
  17. }
  18. else{
  19. for(int x : c){
  20. for(int y : l){
  21. if(abs(y - x) == 1){
  22. cout << "YES";
  23. return 0;
  24. }
  25. }
  26. }
  27. cout << "NO";
  28. }
  29. }
  30.  
Success #stdin #stdout 0.01s 5308KB
stdin
6
78 17 17 42 11 43 
stdout
YES