Submission #579718

#TimeUsernameProblemLanguageResultExecution timeMemory
579718Omar_ElgedawyCollecting Stamps 3 (JOI20_ho_t3)C++14
15 / 100
2076 ms152400 KiB
#include <bits/stdc++.h> using namespace std; #define cin(vec) for(auto& i : vec) cin >> i #define cout(vec) for(auto& i : vec) cout << i << " "; cout << "\n"; #define fast ios::sync_with_stdio(0);cin.tie(0); #define loop(i,a,b) for (int i = a; i < b; i++) #define F first #define S second #define pb(n) push_back(n) #define pf(n) push_front(n) #define dci(d) fixed<<setprecision(d) #define sp ' ' #define el '\n' #define all(v) v.begin(),v.end() #define int long long int dx[8]= {0,0,1,-1,-1,1,1,-1}; int dy[8]= {-1,1,0,0,-1,1,-1,1}; int const N=1e4+5,M=1e3+1,Mod=1e9+7; int a[202],t[202],n,len; map<pair<pair<pair<int,int>,int>,int>,int>m; map<pair<pair<pair<int,int>,int>,int>,bool>vis; int rec(int l,int r,int loc,int time){ if(l==r){ return 0; } if(vis[make_pair(make_pair(make_pair(l,r),loc),time)]){ return m[make_pair(make_pair(make_pair(l,r),loc),time)]; } vis[make_pair(make_pair(make_pair(l,r),loc),time)]=1; int mx=0; if(!loc){ mx=max(rec(l-1,r,0,time+(a[l]-a[l-1]))+((time+(a[l]-a[l-1]))<=t[l-1]) ,rec(l-1,r,1,time+(len-a[l])+a[r])+((time+(len-a[l])+a[r])<=t[r])); } else{ mx=max(rec(l,r+1,0,time+(len-a[l])+a[r])+((time+(len-a[l])+a[r])<=t[l]) ,rec(l,r+1,1,time+(a[r+1]-a[r]))+((time+(a[r+1]-a[r]))<=t[r+1])); } // if(l==5&&r==1) // cout<<l<<' '<<r<<' '<<loc<<' '<<time<<' '<<mx<<el; return m[make_pair(make_pair(make_pair(l,r),loc),time)]=mx; } void testcase(int h){ cin>>n>>len; for(int i=1;i<=n;i++)cin>>a[i]; for(int i=1;i<=n;i++)cin>>t[i]; cout<<max(rec(n,1,0,len-a[n])+(len-a[n]<=t[n]),rec(n,1,1,a[1])+(a[1]<=t[1])); } int32_t main() { // fast testcase(1); // int tc;cin>>tc;for(int i=1;i<=tc;i++)testcase(i); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...