# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
205324 | TadijaSebez | Collecting Stamps 3 (JOI20_ho_t3) | C++11 | 146 ms | 135544 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;
#define ll long long
const ll inf=9e18;
const int N=205;
void ckmn(ll &a,ll b){a=min(a,b);}
ll dp[N][N][2][N];
int x[N],t[N];
int main(){
int n,L;
scanf("%i %i",&n,&L);
for(int i=1;i<=n;i++)scanf("%i",&x[i]);
for(int i=1;i<=n;i++)scanf("%i",&t[i]);
for(int i=0;i<N;i++)for(int j=0;j<N;j++)for(int k=0;k<2;k++)for(int o=0;o<N;o++)dp[i][j][k][o]=inf;
dp[0][n+1][0][0]=0;
for(int sz=n+1;sz>1;sz--){
for(int i=0;i<=n+1-sz;i++){
int j=i+sz;
for(int k=0;k<=n;k++){
if(dp[i][j][0][k]<inf){
ll tme=dp[i][j][0][k]+x[i+1]-x[i];
ckmn(dp[i+1][j][0][k+(tme<=t[i+1])],tme);
tme=dp[i][j][0][k]+x[i]+L-x[j-1];
ckmn(dp[i][j-1][1][k+(tme<=t[j-1])],tme);
}
if(dp[i][j][1][k]<inf){
ll tme=dp[i][j][1][k]+x[i+1]+L-x[j];
ckmn(dp[i+1][j][0][k+(tme<=t[i+1])],tme);
tme=dp[i][j][1][k]+x[j]-x[j-1];
ckmn(dp[i][j-1][1][k+(tme<=t[j-1])],tme);
}
}
}
}
int ans=0;
for(int i=0;i<=n;i++)for(int k=1;k<=n;k++)if(dp[i][i+1][0][k]<inf || dp[i][i+1][1][k]<inf)ans=max(ans,k);
printf("%i\n",ans);
return 0;
}
Compilation message (stderr)
# | 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... |