답안 #875264

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
875264 2023-11-18T22:07:16 Z ForgottenDestiny Hacker (BOI15_hac) C++17
0 / 100
1 ms 348 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";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -