답안 #231918

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231918 2020-05-15T09:53:51 Z IOrtroiii 쌀 창고 (IOI11_ricehub) C++14
68 / 100
21 ms 2560 KB
#ifndef KienVu
#include "ricehub.h"
#endif
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int besthub(int R, int L, int X[], ll B) {
   vector<ll> pref(R + 1);
   for (int i = 0; i < R; ++i) pref[i + 1] = pref[i] + X[i];
   auto cost = [&](int l, int r) {
      int md = (l + r) >> 1;
      return ll(md + 1 - l) * X[md] - (pref[md + 1] - pref[l]) - (r - md) * X[md] + (pref[r + 1] - pref[md + 1]);
   };
   int ans = 0;
   int r = 0;
   for (int l = 0; l < R; ++l) {
      while (r + 1 < R && cost(l, r + 1) <= B) r++;
      ans = max(ans, r - l + 1);
   }
   return ans;
}

#ifdef KienVu
int main() {
   int R, L, B;
   while (cin >> R >> L >> B) {
      int X[R];
      for (int i = 0; i < R; ++i) cin >> X[i];
      cout << besthub(R, L, X, B) << "\n";
   }
}
#endif // KienVu
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 256 KB Output is correct
24 Correct 5 ms 256 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 256 KB Output is correct
28 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 7 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 640 KB Output is correct
2 Correct 7 ms 640 KB Output is correct
3 Correct 21 ms 2560 KB Output is correct
4 Incorrect 21 ms 2560 KB Output isn't correct
5 Halted 0 ms 0 KB -