답안 #1110450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1110450 2024-11-09T13:16:54 Z Icelast 쌀 창고 (IOI11_ricehub) C++17
100 / 100
14 ms 5372 KB
#include "ricehub.h"
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 2*1e5+5, INF = 4e18+9;

int besthub(int R, int L, int X[], long long B)
{
    int n = R;
    vector<ll> a(n+1);
    for(int i = 1; i <= n; i++){
        a[i] = X[i-1];
    }
    vector<ll> pf(n+2, 0);
    for(int i = 1; i <= n; i++){
        pf[i] = pf[i-1]+a[i];
    }
    auto check = [&](int x) -> bool{
        for(int i = x; i <= n; i++){
            int j = i-x+1;
            int m = j+(x+1)/2-1;
            ll left_cost = a[m]*(m-j+1) - (pf[m]-pf[j-1]);
            ll right_cost = (pf[i]-pf[m]) - a[m]*(i-m);
            ll cost = left_cost+right_cost;
            if(cost <= B) return true;
        }
        return false;
    };
    int l = 0, r = n, mid;
    while(l <= r){
        mid = (l+r)/2;
        if(check(mid)){
            l = mid+1;
        }else{
            r = mid-1;
        }
    }
    return l-1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 448 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 376 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 484 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 2 ms 508 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 848 KB Output is correct
2 Correct 3 ms 824 KB Output is correct
3 Correct 10 ms 5200 KB Output is correct
4 Correct 11 ms 5088 KB Output is correct
5 Correct 6 ms 3664 KB Output is correct
6 Correct 8 ms 3664 KB Output is correct
7 Correct 14 ms 4960 KB Output is correct
8 Correct 9 ms 4944 KB Output is correct
9 Correct 5 ms 3540 KB Output is correct
10 Correct 6 ms 3664 KB Output is correct
11 Correct 11 ms 5168 KB Output is correct
12 Correct 10 ms 5372 KB Output is correct
13 Correct 6 ms 3664 KB Output is correct
14 Correct 7 ms 3816 KB Output is correct
15 Correct 9 ms 4432 KB Output is correct
16 Correct 8 ms 4432 KB Output is correct
17 Correct 9 ms 4944 KB Output is correct
18 Correct 10 ms 4896 KB Output is correct
19 Correct 10 ms 5072 KB Output is correct
20 Correct 9 ms 4916 KB Output is correct