Submission #166633

# Submission time Handle Problem Language Result Execution time Memory
166633 2019-12-03T10:27:46 Z egekabas Nizin (COCI16_nizin) C++14
100 / 100
82 ms 10252 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll n;
ll a[1000009];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n;
    for(ll i = 0; i < n; ++i)
        cin >> a[i];
    ll l = 0, r = n-1;
    ll suml = 0, sumr = 0;
    ll ans = 0;
    while(l < r){
        suml += a[l];
        sumr += a[r];
        a[l] = a[r] = 0;
        if(suml == sumr){
            ++l, --r;
        }
        else if(suml > sumr){
            ++ans;
            --r;
        }
        else{
            ++ans;
            ++l;
        }
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1076 KB Output is correct
2 Correct 10 ms 1528 KB Output is correct
3 Correct 10 ms 1376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 3708 KB Output is correct
2 Correct 35 ms 4472 KB Output is correct
3 Correct 42 ms 5240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 7808 KB Output is correct
2 Correct 64 ms 8256 KB Output is correct
3 Correct 73 ms 9208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 10064 KB Output is correct
2 Correct 81 ms 10252 KB Output is correct
3 Correct 79 ms 10236 KB Output is correct