This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "ricehub.h"
#include <iostream>
using namespace std;
#define ll long long
int besthub(int R, int L, int X[], long long B)
{
ll ans = 0;
for(ll i=0;i<R;i++){
ll temp_counter=0;
ll temp_pos=0;
ll cur_cost = 0;
ll prev_pos = 0;
for(ll j=i;j<R;j++){
prev_pos = temp_pos;
temp_pos = ((temp_pos * temp_counter) + X[j]) / (temp_counter+1);
cur_cost += abs(prev_pos-temp_pos)*temp_counter;
cur_cost += X[j] - temp_pos;
temp_counter ++;
if(cur_cost <= B){
ans=max(ans,(j-i)+1);
}else{
break;
}
// cout << temp_counter << " " << temp_pos << " " << cur_cost << endl;
}
}
// cout << ans << endl;
return ans;
}
# | 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... |