# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28766 | 2017-07-16T23:15:49 Z | h0ngjun7 | 쌀 창고 (IOI11_ricehub) | C++14 | 23 ms | 5020 KB |
#include "ricehub.h" int besthub(int R, int L, int X[], long long B) { int l = 0, r = R, ans = 0; while (l <= r) { int m = (l + r) / 2; long long dist = 0; int left, right, mid, ok = 0; int ln = 0, rn = 0; for (int i = 0; i < R && !ok; i++) { if (i + 1 == m) { left = (i + 1) - m, right = i; mid = (left + right) / 2; for (int j = left; j < mid; j++) dist += X[mid] - X[j], ln++; for (int j = mid + 1; j <= right; j++) dist += X[j] - X[mid], rn++; if (dist <= B) ok = 1; } else if (i + 1 > m) { dist -= X[mid] - X[left]; left++; dist += 1LL * (X[mid + 1] - X[mid]) * (ln - rn); mid++; dist += X[right + 1] - X[mid]; right++; if (dist <= B) ok = 1; } } if (ok) { if (ans < m) ans = m; l = m + 1; } else r = m - 1; } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5020 KB | Output is correct |
2 | Correct | 0 ms | 5020 KB | Output is correct |
3 | Correct | 0 ms | 5020 KB | Output is correct |
4 | Correct | 0 ms | 5020 KB | Output is correct |
5 | Correct | 0 ms | 5020 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5020 KB | Output is correct |
2 | Correct | 0 ms | 5020 KB | Output is correct |
3 | Correct | 0 ms | 5020 KB | Output is correct |
4 | Correct | 0 ms | 5020 KB | Output is correct |
5 | Correct | 0 ms | 5020 KB | Output is correct |
6 | Correct | 0 ms | 5020 KB | Output is correct |
7 | Correct | 0 ms | 5020 KB | Output is correct |
8 | Correct | 0 ms | 5020 KB | Output is correct |
9 | Correct | 0 ms | 5020 KB | Output is correct |
10 | Correct | 0 ms | 5020 KB | Output is correct |
11 | Correct | 0 ms | 5020 KB | Output is correct |
12 | Correct | 0 ms | 5020 KB | Output is correct |
13 | Correct | 0 ms | 5020 KB | Output is correct |
14 | Correct | 0 ms | 5020 KB | Output is correct |
15 | Correct | 0 ms | 5020 KB | Output is correct |
16 | Correct | 0 ms | 5020 KB | Output is correct |
17 | Correct | 0 ms | 5020 KB | Output is correct |
18 | Correct | 0 ms | 5020 KB | Output is correct |
19 | Correct | 0 ms | 5020 KB | Output is correct |
20 | Correct | 0 ms | 5020 KB | Output is correct |
21 | Correct | 0 ms | 5020 KB | Output is correct |
22 | Correct | 0 ms | 5020 KB | Output is correct |
23 | Correct | 0 ms | 5020 KB | Output is correct |
24 | Correct | 0 ms | 5020 KB | Output is correct |
25 | Correct | 0 ms | 5020 KB | Output is correct |
26 | Correct | 0 ms | 5020 KB | Output is correct |
27 | Correct | 0 ms | 5020 KB | Output is correct |
28 | Correct | 0 ms | 5020 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5020 KB | Output is correct |
2 | Correct | 0 ms | 5020 KB | Output is correct |
3 | Correct | 0 ms | 5020 KB | Output is correct |
4 | Correct | 0 ms | 5020 KB | Output is correct |
5 | Correct | 0 ms | 5020 KB | Output is correct |
6 | Correct | 0 ms | 5020 KB | Output is correct |
7 | Correct | 0 ms | 5020 KB | Output is correct |
8 | Correct | 0 ms | 5020 KB | Output is correct |
9 | Correct | 0 ms | 5020 KB | Output is correct |
10 | Correct | 0 ms | 5020 KB | Output is correct |
11 | Correct | 0 ms | 5020 KB | Output is correct |
12 | Correct | 0 ms | 5020 KB | Output is correct |
13 | Correct | 0 ms | 5020 KB | Output is correct |
14 | Correct | 0 ms | 5020 KB | Output is correct |
15 | Correct | 0 ms | 5020 KB | Output is correct |
16 | Correct | 0 ms | 5020 KB | Output is correct |
17 | Correct | 0 ms | 5020 KB | Output is correct |
18 | Correct | 0 ms | 5020 KB | Output is correct |
19 | Correct | 0 ms | 5020 KB | Output is correct |
20 | Correct | 0 ms | 5020 KB | Output is correct |
21 | Correct | 0 ms | 5020 KB | Output is correct |
22 | Correct | 0 ms | 5020 KB | Output is correct |
23 | Correct | 0 ms | 5020 KB | Output is correct |
24 | Correct | 0 ms | 5020 KB | Output is correct |
25 | Correct | 0 ms | 5020 KB | Output is correct |
26 | Correct | 0 ms | 5020 KB | Output is correct |
27 | Correct | 0 ms | 5020 KB | Output is correct |
28 | Correct | 0 ms | 5020 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5020 KB | Output is correct |
2 | Correct | 3 ms | 5020 KB | Output is correct |
3 | Correct | 16 ms | 5020 KB | Output is correct |
4 | Correct | 23 ms | 5020 KB | Output is correct |
5 | Correct | 9 ms | 5020 KB | Output is correct |
6 | Correct | 9 ms | 5020 KB | Output is correct |
7 | Correct | 16 ms | 5020 KB | Output is correct |
8 | Correct | 16 ms | 5020 KB | Output is correct |
9 | Correct | 6 ms | 5020 KB | Output is correct |
10 | Correct | 6 ms | 5020 KB | Output is correct |
11 | Correct | 16 ms | 5020 KB | Output is correct |
12 | Correct | 19 ms | 5020 KB | Output is correct |
13 | Correct | 9 ms | 5020 KB | Output is correct |
14 | Correct | 9 ms | 5020 KB | Output is correct |
15 | Correct | 9 ms | 5020 KB | Output is correct |
16 | Correct | 19 ms | 5020 KB | Output is correct |
17 | Correct | 13 ms | 5020 KB | Output is correct |
18 | Correct | 16 ms | 5020 KB | Output is correct |
19 | Correct | 16 ms | 5020 KB | Output is correct |
20 | Correct | 16 ms | 5020 KB | Output is correct |