# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
434156 | 2021-06-20T15:58:33 Z | illyakr | 쌀 창고 (IOI11_ricehub) | C++14 | 129 ms | 3268 KB |
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; #define ll long long ll Abs(ll x) { if (x < 0)return -x; return x; } ll have; ll n; ll a[101010]; ll res = 0; ll pref[101010]; ll gt(ll l, ll r) { return pref[r] - pref[l - 1]; } ll scbp(ll sum, ll id) { ll l = 0, r = id + 1; while (l + 1 < r) { ll mid = (l + r) / 2; ll md = (a[id] * (id - mid + 1)) - gt(mid, id); if (md + sum > have)l = mid; else r = mid; } return r; } int besthub(int R, int L, int X[], long long B) { n = R; for (ll i = 0; i < R; i++) a[i + 1] = X[i]; have = B; for (ll i = 1; i <= n; i++) { pref[i] = pref[i - 1] + a[i]; } ll sumL = 0, sumR = 0; for (ll i = 1; i <= n; i++)sumR += a[i]; for (ll i = 1; i <= n; i++) { ll l = i - 1, r = n + 1; while (l + 1 <= r) { if (l + 1 == r)break; ll mid = (l + r) / 2; ll cnt = gt(i, mid) - (a[i] * (mid - i + 1)); if (cnt > have){r = mid;continue;} ll id = scbp(cnt, i); res = max(res, mid - id + 1); if (id == 1){l = mid;continue;} if (abs(a[id - 1] - a[i]) < abs(a[mid] - a[i])){r = mid;continue;} l = mid; } } return res; } /** 5 20 6 1 2 10 12 14 3 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 204 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 1 ms | 204 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 204 KB | Output is correct |
27 | Correct | 1 ms | 204 KB | Output is correct |
28 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 3 ms | 332 KB | Output is correct |
22 | Correct | 4 ms | 332 KB | Output is correct |
23 | Correct | 3 ms | 332 KB | Output is correct |
24 | Correct | 4 ms | 332 KB | Output is correct |
25 | Correct | 3 ms | 332 KB | Output is correct |
26 | Correct | 5 ms | 332 KB | Output is correct |
27 | Correct | 4 ms | 332 KB | Output is correct |
28 | Correct | 4 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 588 KB | Output is correct |
2 | Correct | 7 ms | 700 KB | Output is correct |
3 | Correct | 84 ms | 2188 KB | Output is correct |
4 | Correct | 129 ms | 2252 KB | Output is correct |
5 | Correct | 18 ms | 1184 KB | Output is correct |
6 | Correct | 17 ms | 1288 KB | Output is correct |
7 | Correct | 102 ms | 2248 KB | Output is correct |
8 | Correct | 104 ms | 2252 KB | Output is correct |
9 | Correct | 44 ms | 1272 KB | Output is correct |
10 | Correct | 44 ms | 1228 KB | Output is correct |
11 | Correct | 84 ms | 2240 KB | Output is correct |
12 | Correct | 111 ms | 2252 KB | Output is correct |
13 | Correct | 26 ms | 1276 KB | Output is correct |
14 | Correct | 25 ms | 1612 KB | Output is correct |
15 | Correct | 61 ms | 2524 KB | Output is correct |
16 | Correct | 99 ms | 2528 KB | Output is correct |
17 | Correct | 77 ms | 2972 KB | Output is correct |
18 | Correct | 97 ms | 2980 KB | Output is correct |
19 | Correct | 82 ms | 3120 KB | Output is correct |
20 | Correct | 115 ms | 3268 KB | Output is correct |