fork(11) download
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. #ifndef ONLINE_JUDGE
  8. freopen("date.in","r",stdin);
  9. freopen("date.out","w",stdout);
  10. #endif
  11. int x = 0, y, n, sol = 0,energy = 0;
  12. cin >> n;
  13. for(int i = 1;i <= n; ++i)
  14. {
  15. cin >> y;
  16. energy += x-y;
  17. if(energy < 0){
  18. sol += -energy;
  19. energy = 0;
  20. }
  21. x = y;
  22. }
  23. cout<<sol<<"\n";
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 3300KB
stdin
Standard input is empty
stdout
0