답안 #1023098

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023098 2024-07-14T09:38:07 Z Almonther Hacker (BOI15_hac) C++
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>

#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
ll n;
ll arr[1000001];
ll precal[1000001];
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>arr[i];
    for(int i=1;i<=n/2;i++) precal[1]+=arr[i];
    ll last=n/2+1;
    for(int i=2,j=n/2+1;max(i,j)<=n;i++,j++){
        precal[i]=precal[i-1]+arr[j]-arr[i-1];
        last=i;
    }
    for(int j=1,i=last+1;max(i,j)<=n;i++,j++) precal[i]=precal[i-1]+arr[j]-arr[i-1];
    ll sum=0,mx=-1;
    for(int i=1;i<=n;i++){
        // co precal[i]<<' ';
        sum+=arr[i];
    }
    // co '\n';
    sort(precal+1,precal+1+n);
    reverse(precal+1,precal+1+n);
    if(n==2){
        co sum-precal[2];
    }
    else{
        if(n%2==0) co sum-precal[3];
        else co sum-precal[2];
    }
}
int main()
{
    suiii
    int tt=1;
    // cin>>tt;
    while(tt--){
        solve();
    }
    return 0;
}

Compilation message

hac.cpp: In function 'void solve()':
hac.cpp:23:14: warning: unused variable 'mx' [-Wunused-variable]
   23 |     ll sum=0,mx=-1;
      |              ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2392 KB Output isn't correct
3 Halted 0 ms 0 KB -