# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99998 | rocketninja7 | Roller Coaster Railroad (IOI16_railroad) | C++14 | 99 ms | 5048 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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(memo[curr][bitmask]!=-1){
return memo[curr][bitmask];
}
long long int ans=15000000000;
for(int i=0;i<s.size();i++){
if(bitmask&(1<<i)){
ans=std::min(ans, recursion(i, bitmask-(1<<i), s, t)+t[curr]-s[i]);
}
}
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){
long long int ans=15000000000;
for(int i=0;i<n;i++){
ans=std::min(ans, recursion(i, (1<<n)-1-(i<<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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |