Submission #852984

#TimeUsernameProblemLanguageResultExecution timeMemory
852984waldiRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
40 ms14008 KiB
#include <bits/stdc++.h> #include "railroad.h" #define FOR(i,p,k) for(int i=(p);i<=(k);++i) #define REP(i,n) FOR(i,0,(n)-1) #define inf 1000000000000000000ll using namespace std; typedef long long ll; ll plan_roller_coaster(vector<int> s, vector<int> t) { int n = s.size(); vector<vector<ll>> dp(1<<n, vector<ll>(n, inf)); FOR(maska, 1, (1<<n)-1) REP(ost, n) if(maska>>ost&1){ if(__builtin_popcount(maska) == 1) dp[maska][ost] = 0ll; REP(i, n) if(!(maska>>i&1)) dp[maska+(1<<i)][i] = min(dp[maska+(1<<i)][i], dp[maska][ost] + max(0, t[ost]-s[i])); } ll wyn = inf; REP(i, n) wyn = min(wyn, dp[(1<<n)-1][i]); return wyn; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...