| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 477018 | Mher | 쌀 창고 (IOI11_ricehub) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <bitset>
using namespace std;
const int N = 200003;
long long r, l, b;
long long x[N], p[N];
long long sum(int xl, int xr)
{
return max(0ll, p[xr] - p[xl - 1]);
}
long long cost(int xl, int xr)
{
int xm = (xl + xr) / 2;
return sum(xm + 1, xr) - sum(xl, xm - ((xr - xl) % 2 == 0));
}
long long search(int ind)
{
int xl = ind, xr = r;
while (xl < xr)
{
int xm = (xl + xr + 1) / 2;
if (cost(ind, xm) <= b)
{
xl = xm;
}
else
{
xr = xm - 1;
}
}
return xl - ind + 1;
}
int besthub(int R, int L, int X[], ll B) {
r = R;
l = L;
b = B;
for (int i = 1; i <= r; i++)
{
x[i] = X[i - 1];
}
for (int i = 1; i <= r; i++)
{
p[i] = x[i] + p[i - 1];
}
long long ans = 0;
for (int i = 1; i <= r; i++)
{
ans = max(ans, search(i));
}
return ans;
}
