Submission #875917

#TimeUsernameProblemLanguageResultExecution timeMemory
875917AverageAmogusEnjoyerRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
42 ms23380 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> bool cmin(T &i, T j) { return i > j ? i=j,1:0; } template<class T> bool cmax(T &i, T j) { return i < j ? i=j,1:0; } const int N=16; const ll inf = 1e18; ll dp[1<<N][N]; int n; ll plan_roller_coaster(vector<int> s,vector<int> t) { n = int(s.size()); memset(dp,0x3f,sizeof(dp)); for (int i=0;i<n;i++) { dp[1<<i][i]=0LL; } for (int mask=1;mask<(1<<n);mask++) { for (int i=0;i<n;i++) { if (mask&(1<<i)) { // possible endpoint if (dp[mask][i]<=inf) { continue; } for (int j=0;j<n;j++) { if (i!=j&&mask&(1<<j)) { cmin(dp[mask][i], dp[mask^(1<<i)][j]+max(0,t[j]-s[i])); } } } } } ll ans = inf; for (int i=0;i<n;i++) { cmin(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...