# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
334598 | sahil_k | 쌀 창고 (IOI11_ricehub) | C++14 | 25 ms | 1900 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <iostream>
#include <cmath>
using namespace std;
bool check (int n, int pos[], long long b, int len) {
long long total = 0;
for (int i=0; i<len; i++) {
total += abs(pos[i]-pos[len/2]);
}
if (total <= b) return true;
for (int i=0; i<n-len; i++) {
total -= pos[len/2+i]-pos[i];
total += pos[i+len]-pos[len/2+i+1];
if (len%2 == 0) total += pos[len/2+i+1]-pos[len/2+i];
if (total <= b) return true;
}
return false;
}
int besthub (int n, int max_x, int pos[], long long b) {
int o;
int l = 1, r = n, m;
while (l <= r) {
m = (l+r)/2;
bool ans = check(n, pos, b, m);
if (ans) {
o = m;
l = m+1;
} else {
r = m-1;
}
}
return o;
}
컴파일 시 표준 에러 (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... |