Submission #510073

# Submission time Handle Problem Language Result Execution time Memory
510073 2022-01-14T16:20:10 Z Jean7 Nizin (COCI16_nizin) C++14
100 / 100
74 ms 8832 KB
#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() && d.size() > 1 )
    {
        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
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 844 KB Output is correct
2 Correct 6 ms 1224 KB Output is correct
3 Correct 6 ms 1216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 3148 KB Output is correct
2 Correct 24 ms 3904 KB Output is correct
3 Correct 32 ms 4548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 6500 KB Output is correct
2 Correct 50 ms 7120 KB Output is correct
3 Correct 74 ms 7944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 8312 KB Output is correct
2 Correct 68 ms 8748 KB Output is correct
3 Correct 66 ms 8832 KB Output is correct