Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define in freopen("input.txt","r",stdin);
- #define out freopen("output.txt","w",stdout);
- using namespace std;
- int main()
- {
- //in;
- //out;
- int a , b[1000005] , i , j;
- cin >> a;
- for( i = 1; i <= a; i ++ ){
- cin >> b[i];
- }
- int ind1 = 1 , ind2 = a ,ans = 0;
- while( ind1 < ind2 ){
- if( b[ind1] > b[ind2] ){
- b[ind2 - 1] = b[ind2] + b[ind2 - 1];
- ind2 --;
- ans ++;
- }
- else if( b[ind1] < b[ind2] ){
- b[ind1 + 1] = b[ind1] + b[ind1 + 1];
- ind1 ++;
- ans ++;
- }
- else{
- ind1 ++;
- ind2 --;
- }
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement