답안 #418370

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
418370 2021-06-05T10:22:37 Z temurbek_khujaev 쌀 창고 (IOI11_ricehub) C++17
26 / 100
1000 ms 2524 KB
#include "ricehub.h"
#include <bits/stdc++.h>
 
using namespace std;
 
 
int besthub(int R, int L, int  X[], long long B) {
    int ans = 0;
    vector<long long> pref(R, 0);
    for (int i = 0; i < R; i++) {
        pref[i] = i == 0 ? X[0] : pref[i - 1] + X[i];
    }
    for (int i = 0; i < R; i++) {
        int l = 1, r = R;
        while (l <= r) {
            int m = (l + r) >> 1;
            int left = i - m / 2 + 1;
            int right = i + (m + 1) / 2;
            bool good = false;
            if (left >= 0 && right < R) {
                long long s = 0;
                assert(right - left + 1 == m);
                for (int j = left; j <= right; j++) {
                    s += abs(X[i] - X[j]);
                }
                good = s <= B;
//                long long d1 = pref[right] - pref[i] - (i + 1) * 1ll * X[i];
//                long long d2 = (X[i] - X[left]) * (m / 2) - pref[i] + left == 0 ? 0 : pref[left - 1];
//                good = d1 + d2 <= B;
            }
 
 
            if (good) {
                l = m + 1;
                ans = max(ans, m);
            } else r = m - 1;
        }
 
 
    }
 
 
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 3 ms 304 KB Output is correct
4 Correct 3 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 2 ms 204 KB Output is correct
8 Correct 2 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 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 3 ms 204 KB Output is correct
14 Correct 3 ms 308 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 2 ms 204 KB Output is correct
18 Correct 2 ms 204 KB Output is correct
19 Correct 3 ms 204 KB Output is correct
20 Correct 3 ms 204 KB Output is correct
21 Correct 26 ms 452 KB Output is correct
22 Correct 25 ms 332 KB Output is correct
23 Correct 80 ms 460 KB Output is correct
24 Correct 81 ms 332 KB Output is correct
25 Correct 81 ms 332 KB Output is correct
26 Correct 81 ms 380 KB Output is correct
27 Correct 92 ms 332 KB Output is correct
28 Correct 91 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 272 ms 460 KB Output is correct
2 Correct 271 ms 572 KB Output is correct
3 Execution timed out 1085 ms 2524 KB Time limit exceeded
4 Halted 0 ms 0 KB -