답안 #521173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
521173 2022-02-01T07:03:19 Z Jomnoi 쌀 창고 (IOI11_ricehub) C++17
0 / 100
18 ms 2604 KB
#include <bits/stdc++.h>
#include "ricehub.h"
#define DEBUG 0
using namespace std;

const int N = 1e5 + 10;

int n;
long long lim;
long long x[N];

bool check(int sz) {
    int mid = (sz + 1) / 2;
    long long L = 0, R = 0;
    for(int i = 1; i < mid; i++) {
        L += x[mid] - x[i];
    }
    for(int i = mid + 1; i <= sz; i++) {
        R += x[i] - x[mid];
    }
    if(L + R <= lim) {
        return true;
    }

    int l = 2, r = sz + 1;
    for(int m = mid + 1; r <= n; m++, l++, r++) {
        L -= x[m - 1] - x[l - 1];
        L += x[m] - x[m - 1];
        R -= x[m] - x[m - 1];
        R += x[r] - x[m];
        if(L + R <= lim) {
            return true;
        }
    }
    return false;
}

int besthub(int R, int L, int X[], long long B) {
    n = R;
    lim = B;
    for(int i = 1; i <= R; i++) {
        x[i] = X[i - 1];
    }

    int l = 1, r = R, pos = -1;
    while(l <= r) {
        int mid = (l + r) / 2;

        if(check(mid) == true) {
            pos = mid;
            l = mid + 1;
        }
        else {
            r = mid - 1;
        }
    }
    return pos;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Incorrect 0 ms 296 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 300 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 0 ms 216 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 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 0 ms 300 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Incorrect 0 ms 204 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 304 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 Incorrect 0 ms 204 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 624 KB Output is correct
2 Correct 3 ms 588 KB Output is correct
3 Correct 12 ms 2476 KB Output is correct
4 Correct 11 ms 2424 KB Output is correct
5 Correct 5 ms 1160 KB Output is correct
6 Correct 5 ms 1228 KB Output is correct
7 Correct 11 ms 2196 KB Output is correct
8 Correct 10 ms 2132 KB Output is correct
9 Correct 5 ms 1100 KB Output is correct
10 Correct 5 ms 1056 KB Output is correct
11 Correct 18 ms 2604 KB Output is correct
12 Correct 12 ms 2500 KB Output is correct
13 Incorrect 6 ms 1220 KB Output isn't correct
14 Halted 0 ms 0 KB -