Submission #100020

#TimeUsernameProblemLanguageResultExecution timeMemory
100020rocketninja7Roller Coaster Railroad (IOI16_railroad)C++14
34 / 100
780 ms8696 KiB
#include "railroad.h" #include <algorithm> long long int memo[16][1<<16]; long long int recursion(int curr, int bitmask, std::vector<int> s, std::vector<int> t){ if(bitmask==0){ return 0; } int n = (int) s.size(); if(memo[curr][bitmask]!=-1){ return memo[curr][bitmask]; } long long int ans=15000000000; for(int i=0;i<n;i++){ if(bitmask&(1<<i)){ ans=std::min(ans, recursion(i, bitmask-(1<<i), s, t)+std::max(t[curr]-s[i], 0)); } } return memo[curr][bitmask]=ans; } long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); if(n<=16){ for(int i=0;i<n;i++){ for(int j=0;j<(1<<n);j++){ memo[i][j]=-1; } } long long int ans=15000000000; for(int i=0;i<n;i++){ ans=std::min(ans, recursion(i, (1<<n)-1-(1<<i), s, t)); } return ans; } std::pair<int, int> tsect[n]; for(int i=0;i<n;i++){ tsect[i]=std::make_pair(t[i], i); } std::sort(tsect, tsect+n); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...