Submission #890610

#TimeUsernameProblemLanguageResultExecution timeMemory
890610LCJLYCollecting Stamps 3 (JOI20_ho_t3)C++14
5 / 100
2041 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define show(x,y) cout << y << " " << #x << endl; #define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl; #define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl; #define show4(x,y) for(auto it:x) cout << it << " "; cout << #y << endl; typedef pair<int,int>pii; typedef pair<pii,int>pi2; int n=0; int k=0; int pos[205]; int limit[205]; int dp(int l, int r, bool flag, int cur){ if(cur>200) return 0; if(l+1>=r) return 0; int ans=0; int dist=cur; if(!flag) dist+=(pos[l+1]-pos[l]); else dist+=(pos[l+1]+k-pos[r]); ans=max(ans,dp(l+1,r,0,dist)+(dist<=limit[l+1])); int dist2=cur; if(flag) dist2+=(pos[r]-pos[r-1]); else dist2+=(pos[l]+k-pos[r-1]); ans=max(ans,dp(l,r-1,1,dist2)+(dist2<=limit[r-1])); return ans; } void solve(){ cin >> n >> k; for(int x=1;x<=n;x++) cin >> pos[x]; for(int x=1;x<=n;x++) cin >> limit[x]; pos[n+1]=k; cout << dp(0,n+1,0,0); } int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); int t=1; //cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...