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>
#include "ricehub.h"
using namespace std;
typedef long long ll;
ll a[5000][5001], b[5000][5001];
int besthub(int R, int L, int X[], long long B){
for(int i=0;i<R;i++){
for(int j=0;j<=R;j++){
if(j==0){
a[i][j]=0;
}
else if(j-1<=i){
a[i][j]=a[i-1][j-1]+(X[i]-X[i-1])*(j-1);
}else{
a[i][j]=LLONG_MAX;
}
}
}
for(int i=R-1;i>=0;i--){
for(int j=0;j<=R;j++){
if(j==0){
b[i][j]=0;
}
else if(j<=R-i-1){
b[i][j]=b[i+1][j-1]+(X[i+1]-X[i])*j;
}else{
b[i][j]=LLONG_MAX;
}
}
}
int ans=0;
// for(int i=0;i<R;i++){
// for(int j=0;j<=R;j++){
// cout << a[i][j] << ' ';
// }
// cout << '\n';
// }
// for(int i=0;i<R;i++){
// for(int j=0;j<=R;j++){
// cout << b[i][j] << ' ';
// }
// cout << '\n';
// }
for(int i=0;i<R;i++){
int ptr=R;
for(int j=0;j<=R;j++){
if(a[i][j]>B||ptr<0)break;
while(a[i][j]+b[i][ptr]>B){
ptr--;
if(ptr<0)break;
}
if(ptr<0)break;
// cout << i << ' ' << j << ' ' << ptr << '\n';
ans=max(ans,j+ptr);
}
}
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... |