fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int N, m01 = 1001, m02 = 1001, m10 = 1001, m11 = 1001, num, res, R;
  8. cin >> N;
  9. for (; N >=1; --N)
  10. {
  11. cin >> num;
  12. if (num < m01 || num < m02 && num%2==0)
  13. {
  14. if (num < m01)
  15. m01 = num;
  16. else
  17. if (num < m02)
  18. m02 = num;
  19. }
  20. else
  21. if (num < m11 || num < m10)
  22. {
  23. if (num < m10)
  24. m10 = num;
  25. else
  26. if (num < m11)
  27. m11 = num;
  28. }
  29. }
  30. cin >> res;
  31. if (m01+m02>m11+m10)
  32. R = m11+m10;
  33. else
  34. R = m01+m02;
  35.  
  36. cout << "Result: " << R << endl;
  37. if (R == res)
  38. cout << "YES";
  39. else
  40. cout << "NO";
  41.  
  42. return 0;
  43. }
Success #stdin #stdout 0s 3460KB
stdin
12
6
14
88
100
8
35
145
4
59
2
84
666
6
stdout
Result: 10
NO