답안 #137008

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137008 2019-07-26T21:57:13 Z AyaBenSaad 쌀 창고 (IOI11_ricehub) C++14
100 / 100
21 ms 3320 KB
#include <bits/stdc++.h>
#include "ricehub.h"

using namespace std;

int besthub(int R, int L, int X[], long long B){
  long long sum[R+2], a[R+2];
  sum[0] = 0, a[0] = 0;
  for (int i = 1; i <= R; i++) a[i] = X[i-1], sum[i] = sum[i-1] + a[i];
  int ans = 1;
  for (int l = 1; l <= R; l++) {
    for (int r = l+ans; r <= R; r++){
      int mid = (l+r) >> 1;
      long long costleft = (mid-l)*a[mid] - (sum[mid-1]-sum[l-1]);
      long long costright = (sum[r]-sum[mid]) - (r-mid)*a[mid];
      if(costleft + costright <= B) {ans = max(ans, r-l+1); continue;}
      break;
    }
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 396 KB Output is correct
6 Correct 2 ms 404 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 732 KB Output is correct
2 Correct 5 ms 632 KB Output is correct
3 Correct 18 ms 2268 KB Output is correct
4 Correct 18 ms 2296 KB Output is correct
5 Correct 8 ms 1276 KB Output is correct
6 Correct 9 ms 1656 KB Output is correct
7 Correct 16 ms 3064 KB Output is correct
8 Correct 16 ms 3064 KB Output is correct
9 Correct 9 ms 1532 KB Output is correct
10 Correct 8 ms 1656 KB Output is correct
11 Correct 20 ms 3320 KB Output is correct
12 Correct 21 ms 3320 KB Output is correct
13 Correct 10 ms 1656 KB Output is correct
14 Correct 9 ms 1656 KB Output is correct
15 Correct 16 ms 2552 KB Output is correct
16 Correct 16 ms 2552 KB Output is correct
17 Correct 18 ms 2936 KB Output is correct
18 Correct 18 ms 3064 KB Output is correct
19 Correct 19 ms 3192 KB Output is correct
20 Correct 19 ms 3192 KB Output is correct