# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
698628 | Baytoro | Collecting Stamps 3 (JOI20_ho_t3) | C++17 | 196 ms | 135292 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 ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define endl '\n'
#define int long long
#define ll long long
void fopn(string name){
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
const ll INF=1e18,mod=1e9+7;
const int N=205;
int dp[N][N][N][2],x[N],t[N],n,L;
void solve(){
cin>>n>>L;
for(int i=1;i<=n;i++) cin>>x[i];
for(int i=1;i<=n;i++) cin>>t[i];
memset(dp,0x3f3f3f3f,sizeof(dp));
int S=dp[0][0][0][0];
dp[0][0][0][0]=dp[0][0][0][1]=0;
for(int i=0;i<n;i++){
for(int l=0;l<=n;l++){
for(int r=0;r<=n;r++){
if(l+r>=n) continue;
for(int k=0;k<2;k++){
int a=dp[i][l][r][k];
if(k==0) a+=(x[l+1]-x[l]);
else a+=(L-x[n+1-r]+x[l+1]);
dp[i+(a<=t[l+1])][l+1][r][0]=min(dp[i+(a<=t[l+1])][l+1][r][0],a);
a=dp[i][l][r][k];
if(k==1) a+=(x[n+1-r]-x[n-r]+L)%L;
else a+=(x[l]+L-x[n-r]);
dp[i+(a<=t[n-r])][l][r+1][1]=min(dp[i+(a<=t[n-r])][l][r+1][1],a);
}
}
}
}
int ans=0;
for(int i=1;i<=n;i++){
for(int l=0;l<=n;l++)
for(int r=0;r<=n;r++)
if(dp[i][l][r][0]!=S || dp[i][l][r][1]!=S) ans=i;
}
cout<<ans;
}
main(){
ios;
int T=1;
//cin>>T;
while(T--){
solve();
}
}
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... |