fork download
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. void swap(int& a, int& b, int& c) {
  7. if (a > b) std::swap(a,b);
  8. if (b > c) std::swap(b,c);
  9. }
  10.  
  11. int main()
  12. {
  13. int N, m01 = 1002, m02 = 1003, m11 = 1002, m12 = 1003, num, res, R;
  14. cin >> N;
  15. for (; N >=1; --N)
  16. {
  17. cin >> num;
  18. if (num%2==0) swap(m01, m02, num);
  19. else swap(m11, m12, num);
  20. }
  21.  
  22. cin >> res;
  23. if (m01+m02>m11+m12)
  24. R = m11+m12;
  25. else
  26. R = m01+m02;
  27.  
  28. cout << "Result: " << R << endl;
  29. if (R == res)
  30. cout << "YES";
  31. else
  32. cout << "NO";
  33. system("pause>void");
  34. return 0;
  35. }
Success #stdin #stdout #stderr 0s 3464KB
stdin
12
6
14
88
100
8
35
145
4
59
2
84
666
6
stdout
Result: 6
YES
stderr
sh: 1: cannot create void: Permission denied
sh: 1: pause: not found