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 mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
ll res=100000000000000;
vpi par,rap;
vi v;
bool vis[200];
void func(int n,ll speed,int k,ll jem)
{
if (k==n)
{
res=min(res,jem);
return;
}
for (int i=0;i<n;i++)
{
if (!vis[i])
{
vis[i]=1;
v.pb(i);
func(n,par[i].s,k+1,jem+((speed>par[i].f)?speed-par[i].f:0));
v.pop_back();
vis[i]=0;
}
}
}
ll plan_roller_coaster(vi s,vi t)
{
for (int i=0;i<sz(s);i++) par.pb({s[i],t[i]});
for (int i=0;i<sz(s);i++) rap.pb({s[i],i});
sort(par.begin(),par.end());
sort(rap.begin(),rap.end());
func(sz(s),1,0,0);
return res;
}
# | 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... |