Submission #298070

#TimeUsernameProblemLanguageResultExecution timeMemory
298070kevleeRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
85 ms8696 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define mod 1000000007 #define h1 7897897897897897 #define h2 7897466719774591 #define b1 98762051 #define b2 98765431 #define inf 1000000000 #define pi 3.1415926535897932384626 #define LMAX 9223372036854775807 #define ll long long #define fi first #define se second #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vl vector<ll> #define vp vector<pii> #define SET(a, b) memset(a, b, sizeof(a)) #define all(x) (x).begin(), (x).end() #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FORD(i, a, b) for (int i = (a); i >= (b); i--) ll dp[1 << 16][16]; long long plan_roller_coaster(vector<int> s, vector<int> t) { int n = s.size(); if (n > 16) return 0; FOR(mask, 1, (1 << n) - 1) { if (__builtin_popcount(mask) == 1) continue; //cout << mask << ":\n"; FOR(i, 0, n - 1) { if ((1 << i) & mask) { dp[mask][i] = LLONG_MAX; FOR(j, 0, n - 1) { if (i != j && ((1 << j) & mask)) { //cout << "i = " << i << "; j = " << j << "; " << t[j] << ' ' << s[i] << endl; dp[mask][i] = min(dp[mask][i], dp[mask ^ (1 << i)][j] + max(0, t[j] - s[i])); } } } } //FOR(i, 0, n-1) cout << dp[mask][i] << ' '; //cout << endl; } ll ans = LLONG_MAX; FOR(i, 0, n - 1) 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...