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 <bits/stdc++.h>
#define INF LLONG_MAX
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
using namespace std;
int n;
bool used[200003];
vector<int> li,exi;
long long solve(long long speed,long long idx,long long rails){
//debug(rails);
//debugs(speed,idx);
if(speed<=0)
return INF;
if(idx==n)
return rails;
long long ans=INF;
for (int i = 0; i < n; ++i)
{
if(!used[i]){
used[i]=1;
//debug(i);
ans=min(ans,solve(exi[i],idx+1,rails+max(0LL,speed-li[i])));
used[i]=0;
}
}
return ans;
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
n = (int) s.size();
li=s;
exi=t;
return solve(1,0,0);
}
# | 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... |