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;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
long long plan_roller_coaster(vector<int> s, vector<int> t)
{
int n = (int)s.size();
if(n<=16)
{
vector<int> pos(n);
for(int i = 0; i<n; i++)
pos[i] = i;
long long res = 1e18;
do
{
int speed = 1;
long long curr = 0;
for(int i = 0; i<n; i++)
{
if(speed>s[pos[i]])
curr+=speed-s[pos[i]];
speed = t[pos[i]];
}
res = min(res, curr);
}while(next_permutation(pos.begin(), pos.end()));
return res;
}
vector<pair<int, int>> p;
for(int i =0; i<n;i++)
p.pb(mp(t[i], s[i]));
sort(p.begin(), p.end());
long long res = 1;
int speed = 1;
for(int i = 0; i<n; i++)
{
if(speed>p[i].se)
{
res = 0;
break;
}
speed = p[i].fi;
}
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... |