제출 #282404

#제출 시각아이디문제언어결과실행 시간메모리
282404groeneprofRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
80 ms10616 KiB
#include "railroad.h" #include <bits/stdc++.h> #define int long long #define P(a) do{if(debug) cout<<a<<endl;} while(false) #define H(a) P(#a<<": "<<a) #define FR(i,a,b) for(int i = (a); i<(b); i++) #define F(i,n) FR(i,0,n) const int debug = 1; const int inf = 1e18; using namespace std; bool f(int a, int b){ return (a&(1<<b)) != 0; } int n; int dp[(1<<17)][17]; long long plan_roller_coaster(vector<signed> s, vector<signed> t) { n = (int) s.size(); FR(i,1,1<<n) F(j, n) if(f(i,j)){ dp[i][j] = inf; bool bol = true; F(k,n) if(k!=j && f(i,k)){ bol = false; dp[i][j] = min(dp[i][j], dp[i-(1<<j)][k] + max(0, t[k] - s[j])); } if(bol){ dp[i][j] = 0; } /*F(k,n){ cout<<f(i,k); } cout<<" "<<j<<": "<<dp[i][j]<<endl;*/ } int ans = inf; F(i,n){ ans = min(ans, dp[(1<<n)-1][i]); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...