| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 743303 | vjudge1 | Rice Hub (IOI11_ricehub) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
int mid = X[R / 2];
int left = (R / 2) - 1;
int right = (R / 2) + 1;
int possible = 1;
int curcost = 0;
bool breakleft = false;
bool breakright = false;
while (!breakleft || !breakright)
{
int disleft, disright;
if (left >= 0)
disleft = mid - X[left];
else
breakleft = 1;
if (right < R)
disright = X[right] - mid;
else
breakright = 1;
if (disleft > disright && !breakleft)
{
if (disleft + curcost <= B)
{
possible++;
curcost += disleft;
left--;
}
else
{
breakleft = true;
}
if (disright + curcost <= B)
{
possible++;
curcost += disright;
right++;
}
else
{
breakright = true;
}
}
else
{
if (disright + curcost <= B)
{
possible++;
curcost += disright;
right++;
}
else
{
breakright = true;
}
if (disleft + curcost <= B)
{
possible++;
curcost += disleft;
left--;
}
else
{
breakleft = true;
}
}
}
cout << possible;
return possible;
}
int main()
{
int R, L;
long long B;
cin >> R >> L >> B;
int X[R];
for (int i = 0; i < R; ++i)
cin >> X[i];
besthub(R, L, X, B);
}
/*
5 20 6
1 2 10 12 14
*/
