# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
723597 |
2023-04-14T06:00:30 Z |
Mr_Husanboy |
Hacker (BOI15_hac) |
C++17 |
|
230 ms |
14284 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9;
void solve(){
int n; cin >> n;
vector<int> p(n);
for(int i = 0; i < n; i ++) cin >> p[i];
int ans = 0;
for(int i = 1; i < n; i ++){
p[i] += p[i - 1];
}
auto get = [&](int l, int r)->int{
if(l > r){
return p[r] + p[n - 1] - (l ? p[l - 1] : 0);
}
return p[r] - (l ? p[l - 1] : 0);
};
multiset<int> st;
int k = (n + 1) / 2;
for(int i = 0; i < n; i ++){
for(int j = i; j < i + k; j ++){
int r = j % n;
int l = ((r - k + 1) % n + n) % n;
st.insert(get(l, r));
}
ans = max(ans, *st.begin());
break;
}
for(int i = 1; i < n; i ++){
int del = get(((i - k) % n + n) % n, i - 1);
int add = get(((i - k + 1) % n + n) % n, i);
//cout << del << ' ' << add << endl;
st.erase(st.find(del));
st.insert(add);
ans = max(ans, *st.begin());
}
cout << ans;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int testcases = 1;
while(testcases --){
solve();
if(testcases) cout << '\n';
#ifdef LOCAL
else cout << '\n';
cout << "__________________________" << endl;
#endif
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
25 ms |
2816 KB |
Output is correct |
5 |
Correct |
77 ms |
6604 KB |
Output is correct |
6 |
Correct |
82 ms |
7540 KB |
Output is correct |
7 |
Correct |
108 ms |
8812 KB |
Output is correct |
8 |
Correct |
230 ms |
14284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |