#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
const int MAXN = 1e5 + 10;
long long X[MAXN], SX[MAXN];
bool Teste(int R, int L, long long B, int tam)
{
for (int l = 1, r = tam; r <= R; l++, r++)
{
int m = (l + r) / 2;
long long sum = ((m - l + 1) * X[m]) - (SX[m] - SX[l-1]);
sum += (SX[r] - SX[m]) - ((r - m) * SX[m]);
if (sum <= B) return true;
}
return false;
}
int besthub(int R, int L, int _X[], long long B)
{
for (int i = 1; i <= R; i++) X[i] = (long long)(_X[i-1]);
for (int i = 1; i <= R; i++) SX[i] = X[i] + SX[i-1];
int ini = 1; int fim = R;
while (ini < fim)
{
int m = (ini + fim) / 2;
if (ini == fim-1) m = fim;
if (Teste(R, L, B, m)) ini = m;
else fim = m-1;
}
return ini;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |