Submission #784939

#TimeUsernameProblemLanguageResultExecution timeMemory
784939GusterGoose27Roller Coaster Railroad (IOI16_railroad)C++17
34 / 100
37 ms7728 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; const int MAXN = 16; const int MAXM = 1e9+5; const ll inf = (ll)MAXN*MAXM; int nxt[MAXN]; ll dp[MAXN+1][1<<MAXN]; // thing that just happened int n; ll plan_roller_coaster(vector<int> s, vector<int> t) { t.push_back(1); n = s.size(); for (int i = 0; i < n; i++) { dp[i][0] = 0; } for (int mask = 1; mask < (1<<n); mask++) { for (int prev = 0; prev <= n; prev++) { if ((1<<prev)&mask) continue; // if (prev == n && mask < (1<<n)-1) continue; dp[prev][mask] = inf; for (int nxt = 0; nxt < n; nxt++) { if (((1<<nxt)&mask) == 0) continue; dp[prev][mask] = min(dp[prev][mask], dp[nxt][mask^(1<<nxt)]+max(0, t[prev]-s[nxt])); } } } return dp[n][(1<<n)-1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...