Submission #875268

# Submission time Handle Problem Language Result Execution time Memory
875268 2023-11-18T22:20:47 Z ForgottenDestiny Hacker (BOI15_hac) C++17
0 / 100
0 ms 516 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //find maximum of minimum (n+1)/2
    int n;
    cin>>n;
    vector<int> nums(n);
    vector<int> p(n+1);
    int maxi=0;
    for (int i=0;i<n;i++){  
        cin>>nums[i];
    }
    for (int i=1;i<n+1;i++){
        p[i]=nums[i-1]+p[i-1];
    }
    for (int i=0;i<n;i++){
        int cur1=0;
        if(i+(n+1)/2>n){
            // cout<<"e"<<i<<"\n";
            // cout<<p[n]-p[i]<<"\n";
            cur1+=p[n]-p[i];
            cur1+=p[((i+(n+1)/2)%n)]-p[0];
        } else {
            cur1+=p[i+(n+1)/2]-p[i];
        }
        int cur2=0;

        if(i+1-(n+1)/2<0){
            cur2+=p[i+1]-p[0];
            // cout<<"e"<<abs(i+1-(n+1)/2)+1<<"\n";
            cur2+=p[n]-p[n-abs(i+1-(n+1)/2)];
        } else {
            // cout<<"e"<<i<<"\n";
            cur2+=p[i+1]-p[i+1-(n+1)/2];
        }
        // cout<<cur1<<"\n";
        // cout<<cur2<<"\n";
        maxi=max(maxi,min(cur1,cur2));
    }
    cout<<maxi<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 516 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 516 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 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 516 KB Output isn't correct
3 Halted 0 ms 0 KB -