Advertisement
Guest User

Untitled

a guest
Nov 6th, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define in freopen("input.txt","r",stdin);
  3. #define out freopen("output.txt","w",stdout);
  4. using namespace std;
  5. int main()
  6. {
  7. //in;
  8. //out;
  9. int a , b[1000005] , i , j;
  10. cin >> a;
  11. for( i = 1; i <= a; i ++ ){
  12. cin >> b[i];
  13. }
  14. int ind1 = 1 , ind2 = a ,ans = 0;
  15. while( ind1 < ind2 ){
  16. if( b[ind1] > b[ind2] ){
  17. b[ind2 - 1] = b[ind2] + b[ind2 - 1];
  18. ind2 --;
  19. ans ++;
  20. }
  21. else if( b[ind1] < b[ind2] ){
  22. b[ind1 + 1] = b[ind1] + b[ind1 + 1];
  23. ind1 ++;
  24. ans ++;
  25. }
  26. else{
  27. ind1 ++;
  28. ind2 --;
  29. }
  30. }
  31. cout << ans << endl;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement