Submission #949626

# Submission time Handle Problem Language Result Execution time Memory
949626 2024-03-19T13:01:10 Z HossamHero7 Hacker (BOI15_hac) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
    int n;
    cin>>n;
    vector<ll> v(n);
    for(auto &i:v) cin>>i;
    vector<ll> p(n);
    p = v;
    for(int i=1;i<n;i++) p[i] += p[i-1];
    auto getSum = [&](int l,int r){
        if(l <= r) return p[r] - (l ? p[l-1] : 0);
        return p[n-1] - p[l - 1] + p[r];
    };
    ll ans = 0;
    for(int i=0;i<n;i++){
        int x = i+((n+1)/2)-1;
        x %= n;
        ll ans1 = getSum(i,x);
        x = i-((n+1)/2)+1;
        x += n;
        x %= n;
        ll ans2 = getSum(x,i);
        ans = max(ans , min(ans1 , ans2));
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -