| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1299300 | luvna | Hacker (BOI15_hac) | C++20 | 1 ms | 572 KiB |
#include<bits/stdc++.h>
#define MASK(i) (1 << (i))
#define pub push_back
#define all(v) v.begin(), v.end()
#define compact(v) v.erase(unique(all(v)), end(v))
#define pii pair<int,int>
#define fi first
#define se second
#define endl "\n"
#define sz(v) (int)(v).size()
#define dbg(x) "[" #x " = " << (x) << "]"
#define vi vector<int>
using namespace std;
bool START_ALLOC;
template<class T> bool minimize(T& a, T b){if(a > b) return a = b, true;return false;}
template<class T> bool maximize(T& a, T b){if(a < b) return a = b, true;return false;}
typedef long long ll;
typedef long double ld;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rand(ll l, ll r){return uniform_int_distribution<ll>(l, r)(rng);}
const int MAX = 1e6 + 15;
int n, k;
int a[MAX];
ll pref[MAX];
ll calc(int l, int r){
if(r > n) r -= n;
if(l < 1) l += n;
if(l <= r) return pref[r] - pref[l-1];
return pref[n] - (pref[l-1] - pref[r]);
}
ll f(int i){
ll fh = calc(i, i + k - 1);
ll sh = calc(i - k + 1, i);
return min(fh, sh);
}
void solve(){
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
pref[i] = pref[i-1] + a[i];
}
k = (n + 1) / 2;
ll answer = 0;
for(int i = 1; i <= n; i++){
maximize(answer, f(i));
}
cout << answer << endl;
}
bool END_ALLOC;
signed main(){
ios_base::sync_with_stdio(NULL);
cin.tie(0); cout.tie(0);
#define task "task"
cerr << "[Static Memory : " << fixed << setprecision(2) << (((&END_ALLOC) - (&START_ALLOC)) / (1024.0 * 1024.0)) << "mb]\n";
if(fopen(task".INP", "r")){
freopen(task".INP", "r", stdin);
freopen(task".OUT", "w", stdout);
}
int t; t = 1; //cin >> t;
while(t--) solve();
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
