# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
488652 | fun_day | 쌀 창고 (IOI11_ricehub) | C++14 | 0 ms | 0 KiB |
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 <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B){
int best = 0;
for(int i = 0 ; i < R ; i++){
vector<int> sz;
int ans = 0;
for(int j = i + 1 ; j < R ; j++){
if(X[j] - X[i] > B) break;
sz.emplace_back(X[j] - X[i]);
}
for(int j = i - 1 ; j >= 0 ; j--){
if(X[i] - X[j] > B) break;
sz.emplace_back(X[i] - X[j]);
}
sort(sz.begin(),sz.end());
long long len = 0;
for(int j = 0 ; j < (int)sz.size() ; j++){
len += sz[j];
if(len <= B) ans++;
else break;
}
best = max(best , ans);
}
return best + 1;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
return 0;
}