Submission #1081236

#TimeUsernameProblemLanguageResultExecution timeMemory
1081236ALeonidouRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
34 ms10836 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second #define pb push_back #define sz(x) (ll)x.size() typedef vector <ll> vi; typedef pair<ll,ll> ii; typedef vector <ii> vii; #define dbg(x) cout<<#x<<": "<<x<<endl; #define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl; #define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl; void printVct(vi &v){ for (ll i =0; i<sz(v); i++){ cout<<v[i]<<" "; } cout<<endl; } #define INF 1000000000000000000 ll plan_roller_coaster(vector <int> s, vector<int> t) { ll n = sz(s); ll n2 = (1 << n); vii dp(n2, ii(INF,INF)); //dp[subset] = ii(min number of rails, min final speed) dp[0] = ii(0,1); for (ll i =0; i<n2; i++){ // cout<<i<<": "<<dp[i].F<<" "<<dp[i].S<<endl; for (ll j =0; j<n; j++){ if (i & (1 << j)) continue; ll newR = dp[i].F, newS = t[j]; ll nextSet = (i | (1 << j)); if (dp[i].S > s[j]){ newR += dp[i].S - s[j]; } // cout<<"\t"; // dbg3(nextSet, newR, newS); dp[nextSet] = min(dp[nextSet], ii(newR, newS)); } } return dp[n2-1].F; } /* 4 1 7 4 3 5 8 6 6 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...