#include "ricehub.h"
#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
for(ll i = R;i>=1;i--){
ll cost = 0;
ll med = (i/2);
ll l = i/2;
ll r = (i+1)/2;
for(ll j = 0;j<i;j++){
cost += abs(X[med]-X[j]);
}
if(cost<=B) return 1;
for(ll j = i;j<R;j++){
cost -= abs(X[j-i]-X[med]);
cost += abs(X[i]-X[med]);
med+=1;
cost += (X[med]-X[med-1])*(l-r);
if(cost<=B)return 1;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
224 ms |
368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |