Submission #135412

#TimeUsernameProblemLanguageResultExecution timeMemory
135412antimirageRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
124 ms44228 KiB
#include "railroad.h" #include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb push_back #define all(s) s.begin(), s.end() using namespace std; int n; long long dp[1 << 17][18], ans = 1e18; long long plan_roller_coaster(vector <int> a, vector<int> b) { n = a.size(); memset(dp, 0x3f3f3f3f, sizeof(dp)); for (int i = 0; i < n; i++) { dp[1 << i][i] = 0; } for (int mask = 1; mask < (1 << n); mask++) { for (int last = 0; last < n; last++) { if ((mask>>last&1) == 0) continue; for (int j = 0; j < n; j++) { if (mask>>j&1) continue; dp[mask + (1 << j)][j] = min( dp[mask + (1 << j)][j], dp[mask][last] + max(0, b[last] - a[j]) ); } } } for (int i = 0; i < n; i++) 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...