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[16][1000000],g[100],res=1000000000000000000;
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++){
for(int j=0;j<n;j++)
dp[j][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[i][a+(1<<i)]=min(dp[i][a+(1ll<<i)],dp[j][a]+max(0,t[j]-s[i]));
}
}
}
}
}
for(int i=0;i<n;i++){
res=min(res,dp[i][(1<<n)-1]);
}
return res;
}
Compilation message (stderr)
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:19:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v.size();i++){
~^~~~~~~~~
# | 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... |