# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153828 | songc | 도넛 (JOI14_ho_t3) | C++14 | 399 ms | 2936 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
int N;
LL ans, S[101010], RS[101010];
bool chk(LL k){
for (int i=1; i<N; i++){
int l = N+1-(lower_bound(RS+N-i+1, RS+N+1, k+RS[N-i])-RS);
int r = lower_bound(S+i+1, S+N+1, k+S[i])-S;
if (l < 1 || N < r) continue;
if (S[l-1] + S[N] - S[r] >= k) return true;
}
return false;
}
int main(){
scanf("%d", &N);
for (int i=1; i<=N; i++){
scanf("%lld", &S[i]);
RS[N-i+1] = S[i];
}
for (int i=1; i<=N; i++) S[i] += S[i-1], RS[i] += RS[i-1];
LL L=0, R=(1ll<<60);
while (L<=R){
LL mid = (L+R)/2;
if (chk(mid)) ans=mid, L=mid+1;
else R = mid-1;
}
printf("%lld\n", ans);
return 0;
}
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... |