이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
//cout<<i<<"----\n";
for(ll j = 0;j<i;j++){
cost += abs(X[med]-X[j]);
}
if(cost<=B){ return i;}
for(ll j = 1;j<=R-i;j++){
//cout<<cost<<endl;
med++;
cost += abs(i/2)*(X[med]-X[med-1]);
//cout<<cost<<endl;
cost -= abs((i-1)/2)*(X[med]-X[med-1]);
//cout<<cost<<endl;
cost += abs(X[med]-X[j+i-1]);
//cout<<cost<<endl;
cost -= abs(X[med-1]-X[j-1]);
//cout<<cost<<"\n\n\n";
//med+=2;
if(cost<=B){return i;}
}
}
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |