Submission #698063

#TimeUsernameProblemLanguageResultExecution timeMemory
698063myrcellaCollecting Stamps 3 (JOI20_ho_t3)C++17
15 / 100
73 ms85968 KiB
//by szh #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl #define pq priority_queue #define inf 0x3f #define rep(i,a,b) for (int i=a;i<(b);i++) #define MP make_pair #define SZ(x) (int(x.size())) #define ll long long #define mod 1000000007 #define ALL(x) x.begin(),x.end() void inc(int &a,int b) {a=(a+b)%mod;} void dec(int &a,int b) {a=(a-b+mod)%mod;} void MIN(int &a,int b) { if (a==-1) a = b; else a = min(a,b); } int lowbit(int x) {return x&(-x);} ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;} const int maxn = 222; int n,len; int pos[maxn]; int dp[maxn][maxn][maxn][2]; int t[maxn]; int big; int ans = 0; int main() { // freopen("input.txt","r",stdin); std::ios::sync_with_stdio(false);cin.tie(0); memset(dp,-1,sizeof(dp)); dp[0][0][0][0] = dp[0][0][0][1] = 0; cin>>n>>len; pos[0] = 0,pos[n+1] = len; rep(i,1,n+1) cin>>pos[i]; rep(i,1,n+1) cin>>t[i]; rep(i,0,n+1) rep(j,0,n-i+1) rep(k,0,i+j+1) { // cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k][0]<<" "<<dp[i][j][k][1]<<endl; if (dp[i][j][k][0]!=-1) { ans = max(ans,k); int tn = dp[i][j][k][0] + pos[i+1]-pos[i]; // debug(tn); MIN(dp[i+1][j][k+(tn<=t[i+1])][0],tn); tn = dp[i][j][k][0] + pos[i] + len-pos[n-j]; // debug(tn); MIN(dp[i][j+1][k+(tn<=t[n-j])][1],tn); } if (dp[i][j][k][1]!=-1) { ans = max(ans,k); int tn = dp[i][j][k][1] + pos[n-j+1] - pos[n-j]; // debug(tn); MIN(dp[i][j+1][k+(tn<=t[n-j])][1],tn); tn = dp[i][j][k][1] + len-pos[n-j+1] + pos[i+1]; // debug(tn); MIN(dp[i+1][j][k+(tn<=t[i+1])][0],tn); } } cout<<ans; 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...