제출 #1299673

#제출 시각아이디문제언어결과실행 시간메모리
1299673wojtekmal쌀 창고 (IOI11_ricehub)C++20
100 / 100
8 ms584 KiB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define ll long long

int besthub(int R, int L, int X[], long long B)
{
    int maxx = 0;
    int begg = 0, endd = -1;
    int midd = -1;
    int parity = 1;
    ll cost = 0;
    int rice_amount = 0;

    while (true)
    {
        if (parity) midd++;
        parity ^= 1;

        if (cost <= B)
        {
            maxx = max(maxx, rice_amount);
            endd++;
            if (endd == R) break;
            rice_amount++;
            cost += X[endd] - X[midd];
        }
        else
        {
            cost -= X[midd] - X[begg];
            begg++;
            rice_amount--;
        }
    }

    return maxx;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...