답안 #949236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949236 2024-03-19T04:03:19 Z Sir_Ahmed_Imran Hacker (BOI15_hac) C++17
0 / 100
6 ms 13016 KB
                              ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define append push_back
#define add insert
#define nl "\n"
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define N 500001
int n;
int a[N];
int Add[N];
int REM[N];
int Remov[N];
int get(int l,int r){
    if(l>r)
        return a[n]-a[l-1]+a[r];
    return a[r]-a[l-1];
}
void solve(){
    int m,o,p,q;
    cin>>n;
    m=n/2;
    for(int i=o=1;i<=n;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    for(int i=1;i<m;i++)
        Add[i+1]=get(n-m+i+1,i);
    Add[m+1]=get(1,m);
    priority_queue<int> Q;
    for(int i=m+1;i<=n;i++){
        Q.push(get(i-m+1,i));
        Add[i+1]=get(i-m+1,i);
        REM[i-m+1]=get(i-m+1,i);
    }
    for(int i=1;i<=n;i++){
        Q.push(Add[i]);
        Remov[REM[i]]++;
        while(Remov[Q.top()]){
            Remov[Q.top()]--;
            Q.pop();
        }
        o=max(o,a[n]-Q.top());
    }
    cout<<o;
}
int main(){
    L0TA;
    solve();
    return 0;
}

Compilation message

hac.cpp: In function 'void solve()':
hac.cpp:26:13: warning: unused variable 'p' [-Wunused-variable]
   26 |     int m,o,p,q;
      |             ^
hac.cpp:26:15: warning: unused variable 'q' [-Wunused-variable]
   26 |     int m,o,p,q;
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Incorrect 1 ms 6744 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Incorrect 1 ms 6744 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Runtime error 6 ms 13016 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Incorrect 1 ms 6744 KB Output isn't correct
3 Halted 0 ms 0 KB -