# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
51759 | model_code | 도넛 (JOI14_ho_t3) | C++17 | 314 ms | 3836 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// O(N log^2 N) solution
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 1000010;
typedef long long i64;
int N;
i64 A[MAXN];
i64 S[MAXN*4];
int find_next(int pos, i64 C)
{
return upper_bound(S, S+(N*3), S[pos]+C-1) - S;
}
bool check(i64 C)
{
for(int i=0;i<N;i++){
int pos = i;
pos = find_next(pos, C); if(pos > i+N) continue;
pos = find_next(pos, C); if(pos > i+N) continue;
pos = find_next(pos, C); if(pos > i+N) continue;
return true;
}
return false;
}
int main()
{
scanf("%d", &N);
for(int i=1;i<=N;i++) scanf("%lld", A+i);
S[0] = 0;
for(int i=1;i<=N;i++) S[i] = S[i+N] = S[i+2*N] = A[i];
for(int i=1;i<=3*N;i++) S[i] += S[i-1];
i64 left=1, right=S[N]/3;
while(left < right){
i64 mid = (left+right+1)/2;
if(check(mid)){
left = mid;
}else{
right = mid-1;
}
}
printf("%lld\n", left);
return 0;
}
컴파일 시 표준 에러 (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... |