# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153906 | mhy908 | 도넛 (JOI14_ho_t3) | C++14 | 10 ms | 508 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>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define llinf 8987654321987654321
#define inf 1987654321
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n;
LL arr[200010], maxx, ans;
LL f(int stnum, int st, int fin)
{
if(st==fin)return arr[st]-arr[stnum];
LL mid=(st+fin)/2+1;
LL l=arr[mid]-arr[stnum];
int next=lower_bound(arr+mid+1, arr+stnum+n, l+arr[mid])-arr;
if(arr[stnum+n]-arr[next]>=l)return f(stnum, mid, fin);
return f(stnum, st, mid-1);
}
int main()
{
scanf("%d", &n);
for(int i=1; i<=n; i++){
LL temp;
scanf("%lld", &temp);
arr[i]=arr[i-1]+temp;
}
maxx=arr[n];
for(int i=1; i<=n; i++){
arr[i+n]=arr[i]+maxx;
}
for(int i=0; i<n; i++){
ans=max(ans, f(i, i+1, i+n-1));
}
printf("%lld", ans);
}
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... |