# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123473 | baqargam | Roller Coaster Railroad (IOI16_railroad) | C++14 | 83 ms | 10672 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 "bits/stdc++.h"
#include "railroad.h"
using namespace std;
long long j,l,dp[1000000],g[100];
vector<pair<int,int> >v;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
for(int i=0;i<(1<<n);i++){
int ct=__builtin_popcount(i);
v.push_back({ct,i});
}
for(int i=n;i<(1<<n);i++){
dp[i]=1000000000000000000;
}
for(int i=0;i<v.size();i++){
int a=v[i].second;
for(j=a,l=0;j>0;j>>=1,l++)
g[l]=j%2;
for(int j=0;j<l;j++){
if(g[j]==1)
{
for(int i=0;i<n;i++){
if(g[i]==0)
{
dp[a+(1<<i)]=min(dp[a+(1ll<<i)],dp[a]+max(0,s[i]-t[j]));
}
}
}
}
}
return dp[(1<<n)-1];
}
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... |