This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
using namespace std ;
deque <int> d ;
int32_t main ()
{
fastio
int n , x , ans = 0 ;
cin >> n ;
for ( int i = 0 ; i < n; i++ )
{
cin >> x ;
d.push_back(x) ;
}
int j ;
while ( !d.empty() )
{
if ( d.front() < d.back() )
{
j = d.front() ;
d.pop_front() ;
d.front() += j ;
ans++ ;
}
else if ( d.front() > d.back() )
{
j = d.back() ;
d.pop_back() ;
d.back() += j ;
ans++ ;
}
else if ( d.front() == d.back() )
{
d.pop_back() ;
d.pop_front() ;
}
}
cout << ans ;
return 0 ;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |