#include "ricehub.h"
#include <iostream>
#include <algorithm>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
sort(X, X + R);
int n = R;
int from = 0;
int to = 0;
long long cost = 0;
int res = 1;
while (true) {
int currRange = to - from + 1;
to++;
if (to >= n) break;
int newDist = X[to] - X[to - 1];
cost += (long long)currRange * newDist;
while (cost > B) {
if (from > to) return 0;
cost -= (long long)X[to] - X[from];
from++;
}
res = max(res, to - from + 1);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
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 |
3 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |