Submission #1023102

# Submission time Handle Problem Language Result Execution time Memory
1023102 2024-07-14T09:42:25 Z Almonther Hacker (BOI15_hac) C++
0 / 100
1 ms 348 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];
    }
    sort(precal+1,precal+1+n);
    reverse(precal+1,precal+1+n);
    if(n==2){
        co sum-precal[2];
    }
    else{
        co sum-precal[3];
    }
}
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;
      |              ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 1 ms 344 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 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -