#include<bits/stdc++.h>
#include "ricehub.h"
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define f first
#define s second
#define pb push_back
#define p_b pop_back
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
ll n = R, i;
ll h[n+5], pref[n+5];
pref[0] = 0;
for(i = 1; i <= n; i++)
h[i] = X[i-1];
ll res = 0;
for(i = 1; i <= n; i++)
{
int l = i, r = n, ans = i;
while(l <= r)
{
int mid = (l + r) / 2;
if(h[mid] - h[i] > B)
r = mid - 1;
else
{
ans = max(ans, mid);
l = mid + 1;
}
}
res = max(res, ans - i + 1);
}
return res;
}
/*int main()
{
int R, L;
ll B;
cin >> R >> L >> B;
int X[R];
for(int i = 0; i < R; i++)
cin >> X[i];
cout << besthub(R, L, X, B) << "\n";
}
*/
Compilation message
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:19:16: warning: variable 'pref' set but not used [-Wunused-but-set-variable]
19 | ll h[n+5], pref[n+5];
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |