Submission #698614

#TimeUsernameProblemLanguageResultExecution timeMemory
698614BaytoroCollecting Stamps 3 (JOI20_ho_t3)C++17
25 / 100
2093 ms218004 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; map<int,int> dp[N][N]; int x[N],t[N]; int n,L,s; int f(int l, int r){ if(l>r) swap(l,r); return min(r-l,L-r+l); } int rec(int i, int j, int time){ if(abs(i-j)==1) return 0; if(dp[i][j].count(time)) return dp[i][j][time]; int c=i,l=min(i,j),r=max(i,j); int ans=rec(l+1,r,min(s,f(x[c],x[l+1])+time))+(f(x[c],x[l+1])+time<=t[l+1]); ans=max(ans,rec(r-1,l,min(s,f(x[c],x[r-1])+time))+(f(x[c],x[r-1])+time<=t[r-1])); dp[i][j][time]=ans; return ans; } 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]; s=max(s,t[i]+1); } cout<<rec(0,n+1,0); } main(){ ios; int T=1; //cin>>T; while(T--){ solve(); } }

Compilation message (stderr)

ho_t3.cpp:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   44 | 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...