Submission #799670

#TimeUsernameProblemLanguageResultExecution timeMemory
799670KhizriRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
37 ms10544 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define F first #define S second #define INF 1e18 #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define pii pair<int,int> #define pll pair<ll,ll> #define OK cout<<"Ok"<<endl; #define MOD (ll)(1e9+7) const int mxn=20; ll n,dp[(1<<mxn)][mxn]; long long plan_roller_coaster(vector<int> s, vector<int> t) { n = (int) s.size(); for(int mask=1;mask<(1<<n);mask++){ ll mn=INF; if(__builtin_popcount(mask)==1){ for(int i=0;i<n;i++){ if(mask&(1<<i)){ dp[mask][i]=0; } } continue; } for(int i=0;i<n;i++){ if(!(mask&(1<<i))) continue; dp[mask][i]=INF; for(int j=0;j<n;j++){ if(!((mask^(1<<i))&(1<<j))) continue; dp[mask][i]=min(dp[mask][i],dp[mask^(1<<i)][j]+max(0,t[j]-s[i])); } } } ll ans=INF; for(int i=0;i<n;i++){ ans=min(ans,dp[(1<<n)-1][i]); } return ans; } /* g++ railroad.cpp grader.cpp ; .\a.exe 4 1 7 4 3 5 8 6 6 */

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:20:12: warning: unused variable 'mn' [-Wunused-variable]
   20 |         ll mn=INF;
      |            ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...