#include<bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define lli long long
int besthub(int R, int L, int X[], lli B)
{
int ans = 0;
for(int i=0 ; i<R ; i++)
{
int l = i-1, r = i+1, cou = 1;
lli temp = B;
while(l >= 0 && r < R)
{
if(X[i] - X[l] <= X[r] - X[i] && temp >= X[i] - X[l])
{
cou++;
temp -= X[i] - X[l];
l--;
}
else if(X[i] - X[l] > X[r] - X[i] && temp >= X[r] - X[i])
{
cou++;
temp -= X[r] - X[i];
r++;
}
else break ;
}
while(l >= 0)
{
if(temp >= X[i] - X[l])
{
cou++;
temp -= X[i] - X[l];
l--;
}
else break ;
}
while(r < R)
{
if(temp >= X[r] - X[i])
{
cou++;
temp += X[r] - X[i];
r++;
}
else break ;
}
ans = max(ans, cou);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |