Submission #1045477

#TimeUsernameProblemLanguageResultExecution timeMemory
1045477Edu175Roller Coaster Railroad (IOI16_railroad)C++17
34 / 100
36 ms20540 KiB
#include "railroad.h" #include <bits/stdc++.h> #define pb push_back #define fst first #define snd second #define fore(i,a,b) for(ll i=a,ioi=b;i<ioi;i++) #define SZ(x) ((int)x.size()) #define ALL(x) x.begin(),x.end() #define mset(a,v) memset((a),(v),sizeof(a)) #define imp(v) {for(auto dkfjhg:v)cout<<dkfjhg<<" ";cout<<"\n";} using namespace std; typedef long long ll; typedef pair<ll,ll> ii; const ll MAXN=2e5+5,INF=1e15; long long plan_roller_coaster(std::vector<int> A, std::vector<int> B) { vector<ll>a,b; for(auto i:A)a.pb(i); for(auto i:B)b.pb(i); ll n=SZ(a); auto bin=[&](ll mk){ string r; fore(i,0,n)r.pb('0'+(mk>>i&1)); return r; }; vector<vector<ll>>dp(1ll<<n,vector<ll>(n)); fore(mk,1,1ll<<n)fore(x,0,n){ ll &res=dp[mk][x]; res=INF; // if(!mk){res=0;continue;} fore(y,0,n)if(mk>>y&1){ res=min(res,max(b[x]-a[y],0ll)+dp[mk^(1ll<<y)][y]); } // cout<<bin(mk)<<" "<<x<<": "<<res<<"\n\n"; } ll res=INF,u=(1ll<<n)-1; fore(i,0,n)res=min(res,dp[u^(1ll<<i)][i]); return res; }

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:21:7: warning: variable 'bin' set but not used [-Wunused-but-set-variable]
   21 |  auto bin=[&](ll mk){
      |       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...