답안 #744356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744356 2023-05-18T13:36:08 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
100 / 100
17 ms 2516 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
const int maxR = 1e5 + 5;
#define ll long long
ll dp[maxR];

bool check(int window, int R, long long B)
{
    for (int m = (window + 1) / 2; m + (window / 2) <= R; ++m)
    {
        ll rightdis = dp[m + (window / 2)] - dp[m];
        ll leftdis = dp[m - 1 + (window % 2 == 0)] - dp[m - (window / 2) + (window % 2 == 0) - 1];
        ll cost = rightdis - leftdis;
        if (cost <= B)
            return true;
    }
    return false;
}

int besthub(int R, int L, int X[], long long B)
{
    dp[0] = 0;
    for (int i = 0; i < R; ++i)
        dp[i + 1] = dp[i] + X[i];
    int l = 0, r = R + 10, ans = -1;
    while (l <= r)
    {
        int mid = (l + r) / 2;
        //cout << l << " " << mid << " " << r << "\n";
        if (check(mid, R, B))
        {
            l = mid + 1;
            ans = mid;
        }
        else
            r = mid - 1;
    }
    //cout << ans;
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 640 KB Output is correct
2 Correct 3 ms 556 KB Output is correct
3 Correct 17 ms 2480 KB Output is correct
4 Correct 13 ms 2484 KB Output is correct
5 Correct 5 ms 1236 KB Output is correct
6 Correct 6 ms 1236 KB Output is correct
7 Correct 10 ms 2148 KB Output is correct
8 Correct 13 ms 2140 KB Output is correct
9 Correct 6 ms 1184 KB Output is correct
10 Correct 6 ms 1076 KB Output is correct
11 Correct 12 ms 2476 KB Output is correct
12 Correct 11 ms 2516 KB Output is correct
13 Correct 6 ms 1236 KB Output is correct
14 Correct 6 ms 1208 KB Output is correct
15 Correct 8 ms 1876 KB Output is correct
16 Correct 8 ms 1876 KB Output is correct
17 Correct 10 ms 2228 KB Output is correct
18 Correct 11 ms 2192 KB Output is correct
19 Correct 11 ms 2380 KB Output is correct
20 Correct 11 ms 2388 KB Output is correct