fork download
  1. // SIGMA BOY hihihihihihihi
  2.  
  3. #define se second
  4. #define fi first
  5. #define pb push_back
  6. #define pob pop_back
  7. #define bitebi __builtin_popcountll
  8. #include <bits/stdc++.h>
  9.  
  10. using namespace std ;
  11. typedef long long ll;
  12. typedef long double ld;
  13. typedef pair<ll,ll> pll;
  14. typedef pair<ll,int> pli;
  15. typedef pair<int,int> pii;
  16. const ll Mod = 1e9+7;
  17. const ll Maxn = 1e5+69;
  18. const ll oo = 1e18;
  19.  
  20. ll Min[2] = {0,oo} , n , x , cur = 0 , res = -oo;
  21.  
  22. void Do()
  23. {
  24. cin >> n ;
  25. for ( int i = 1 ; i <= n ; ++i)
  26. {
  27. cin >> x;
  28. cur += x;
  29. if(Min[abs(cur)%2]!=oo) res = max(res, cur - Min[abs(cur)%2]);
  30. Min[abs(cur)%2] = min(Min[abs(cur)%2],cur);
  31. }
  32. if(res==oo) cout << "NOT_FOUND";
  33. else cout << res;
  34. }
  35.  
  36. signed main ()
  37. {
  38. ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  39. #define task "test"
  40. if(fopen(task".inp", "r")){
  41. freopen(task".inp", "r", stdin);
  42. freopen(task".out", "w", stdout);
  43. }
  44. int ntest=1;
  45. while(ntest--) Do();
  46.  
  47. cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
  48. }
  49.  
Success #stdin #stdout #stderr 0s 5320KB
stdin
Standard input is empty
stdout
-1000000000000000000
stderr
Time elapsed: 4ms