Submission #698628

#TimeUsernameProblemLanguageResultExecution timeMemory
698628BaytoroCollecting Stamps 3 (JOI20_ho_t3)C++17
100 / 100
196 ms135292 KiB
#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)

ho_t3.cpp:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main(){
      | ^~~~
ho_t3.cpp: In function 'void fopn(std::string)':
ho_t3.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t3.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...