Submission #634126

#TimeUsernameProblemLanguageResultExecution timeMemory
634126uroskCollecting Stamps 3 (JOI20_ho_t3)C++14
100 / 100
117 ms130892 KiB
#define here cerr<<"===========================================\n" #define dbg(x) cerr<<#x<<": "<<x<<endl; #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #define ld double #define ll long long #define llinf 100000000000000000LL // 10^17 #define pb push_back #define popb pop_back #define fi first #define sc second #define endl '\n' #define pll pair<ll,ll> #define pld pair<ld,ld> #define sz(a) (ll)(a.size()) #define all(a) a.begin(),a.end() #define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;} #define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0); using namespace std; using namespace __gnu_pbds; /* ll add(ll x,ll y){ x+=y; if(x<0){ x%=mod; x+=mod; }else{ if(x>=mod) x%=mod; } return x; } ll mul(ll a,ll b){ ll ans = (a*b)%mod; if(ans<0) ans+=mod; return ans; } typedef tree<int,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; typedef tree<int,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll rnd(ll l,ll r){ return uniform_int_distribution<ll>(l,r)(rng); } */ void ckmin(ll &x,ll y){x = min(x,y);} #define maxn 205 ll n,L; ll a[maxn],t[maxn]; ll b[maxn]; ll dp[maxn][maxn][2][maxn]; int main(){ daj_mi_malo_vremena cin >> n >> L; for(ll i = 1;i<=n;i++) cin >> a[i]; for(ll i = 1;i<=n;i++) b[i] = L-a[i]; reverse(b+1,b+n+1); for(ll i = 1;i<=n;i++) cin >> t[i]; for(ll i = 0;i<=n;i++) for(ll j = 0;j<=n;j++) for(ll e = 0;e<=1;e++) for(ll p = 0;p<=n;p++) dp[i][j][e][p] = llinf; dp[1][0][1][a[1]<=t[1]] = a[1]; dp[1][0][1][0] = a[1]; dp[0][1][0][b[1]<=t[n]] = b[1]; dp[0][1][0][0] = b[1]; for(ll s = 1;s<n;s++){ for(ll l = 0;l<=s;l++){ ll r = s-l; for(ll e = 0;e<=1;e++){ for(ll p = 0;p<=n;p++){ ll time = dp[l][r][e][p]; ll dl = a[l+1]-a[l]; if(!e) dl = b[r] + a[l+1]; ll dr = b[r+1] + a[l]; if(!e) dr = b[r+1] - b[r]; if(s==n-1) dl = min(a[l+1]-a[l],b[r]+a[l+1]); if(s==n-1) dr = min(b[r+1]-b[r],b[r+1]+a[l]); ckmin(dp[l+1][r][1][p+((time+dl)<=t[l+1])],time+dl); ckmin(dp[l][r+1][0][p+((time+dr)<=t[n-(r+1)+1])],time+dr); } } } } ll ans = 0; for(ll s = 1;s<=n;s++){ for(ll l = 0;l<=s;l++){ ll r = s-l; for(ll e = 0;e<=1;e++){ for(ll p = 0;p<=n;p++){ if(dp[l][r][e][p]<llinf) ans = max(ans,p); } } } } cout<<ans<<endl; 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...