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