fork download
  1. /*
  2.   Fr: pdtduong
  3.   Note: uoc gi AC (")>
  4.   Wish: HSGS/PTNK 26-27
  5. */
  6. #include<bits/stdc++.h>
  7. using namespace std;
  8. #define int long long
  9. #define endl "\n"
  10. #define lcm(a, b) a*b/__gcd(a, b)
  11. #define fi first
  12. #define se second
  13. #define pb push_back
  14. #define YES cout << "YES\n";
  15. #define NO cout << "NO\n";
  16. const int maxn = 1e6+5, INF = 1e18;
  17. int n, k;
  18. int a[maxn];
  19. signed main() {
  20. ios_base::sync_with_stdio(false);
  21. cin.tie(NULL);
  22. // freopen("LED.INP", "r", stdin);
  23. // freopen("LED.OUT", "w", stdout);
  24. cin >> n >> k;
  25. int sumChan = 0, sumLe = 0;
  26. int minLe = INF, cntLe = 0;
  27. for(int i = 1; i <= n; i++) {
  28. cin >> a[i];
  29. if(a[i] % 2 == 0) {
  30. sumChan += a[i];
  31. } else {
  32. sumLe += a[i];
  33. minLe = min(minLe, a[i]);
  34. cntLe++;
  35. }
  36. }
  37. int ans = 0;
  38. if(cntLe % 2 == 0) {
  39. ans = sumChan + sumLe;
  40. } else {
  41. ans = sumChan + sumLe - minLe;
  42. }
  43. if(ans < k) {
  44. ans = 0;
  45. }
  46. cout << ans;
  47. return 0;
  48. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty