Submission #477827

#TimeUsernameProblemLanguageResultExecution timeMemory
477827BackNoobRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
52 ms10576 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define endl '\n' #define mask(i) (1LL << (i)) #define task "name" #define ull unsigned long long using namespace std; const ll mxN = 220797 + 7; const ll inf = 1e9 + 277; const ll mod = 2147483648; const ll infll = 1e18 + 7; const ll base = 307; template <typename T1, typename T2> bool minimize(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maximize(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false; } int s[mxN] , t[mxN]; ll dp[(1 << 16)][20]; ll plan_roller_coaster(vector<int> s , vector<int> t) { int n = (int) s.size(); if(n > 16) return 0; memset(dp , 0x3f , sizeof(dp)); for(int mask = 0 ; mask < (1 << n) ; mask++) { if(mask == 0) { for(int i = 0 ; i < n ; i++) { if(!(mask & (1 << i)) && s[i] >= 1) { dp[mask | (1 << i)][i] = 0; } } } else { for(int i = 0 ; i < n ; i++) { if((mask & (1 << i)) && dp[mask][i] != dp[0][0]) { for(int j = 0 ; j < n ; j++) { if(!(mask & (1 << j))) { minimize(dp[mask | (1 << j)][j] , dp[mask][i] + max(0 , t[i] - s[j])); } } } } } } ll res = dp[0][0]; for(int i = 0 ; i < n ; i++) { minimize(res , dp[(1 << n) - 1][i]); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...