답안 #1003233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003233 2024-06-20T08:06:21 Z hacizadal 쌀 창고 (IOI11_ricehub) C++17
0 / 100
1 ms 604 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>
ll p[5005];

pll binary1(ll b, ll e, ll num, ll money)
{
    ll l = b, r = e, ans = 0;
    while (l <= r){
        ll m = (l + r)/2;
        if (p[m] - p[b-1] - ((m-b+1)*num) <= money){
            l = m + 1;
            ans = money - (p[m] - p[b-1] - ((m-b+1)*num));
        }
        else {
            r = m - 1;
        }
    }
    return {ans, l-1};
}

pll binary2(ll b, ll e, ll num, ll money)
{
    ll l = b, r = e, ans = 0;
    while (l <= r){
        ll m = (l + r)/2;
        if ((e-m+1)*num - (p[e] - p[m-1]) <= money){
            r = m - 1;
            ans = money - (e-m+1)*num - (p[e] - p[m-1]);
        }
        else {
            l = m + 1;
        }
    }
    return {ans, r+1};
}

int besthub(int n, int l, int a[], long long b)
{
    for (ll i = 0; i<n; i++){
        p[i+1] = p[i] + a[i];
    }
    ll mx = 0;
    for (ll i = 11; i<=11; i++){
        ll x = lower_bound(a, a+n, i) - a;
        pll k = binary1(x+1, n, i, b);
        pll g = binary2(1, x, i, k.first);
        mx = max(mx, (k.second-g.second+1));
        g = binary2(1, x, i, b);
        k = binary1(x+1, n, i, g.first);
        mx = max(mx, (k.second-g.second+1));
    }
    return mx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -