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>
using namespace std;
#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second
#define size(x) (int)x.size()
using ll = long long;
using ii = pair<int, int>;
const ll inf = 1e18 + 69;
namespace sub1
{
void solve(vector<int> s,vector<int> t)
{
int n = size(s);
vector<ii> v(n);
for (int i = 0; i < n; ++i)
v[i] = {s[i], t[i]};
sort(v.begin(), v.end());
ll mn = inf;
do
{
ll ctr = 0;
for (int i = 0, cur = 1; i < n; ++i)
{
ctr += max(0, cur - v[i].f1);
cur = v[i].s2;
}
mn = min(mn, ctr);
} while (next_permutation(v.begin(), v.end()));
}
};
ll plan_roller_coaster(vector<int> s, vector<int> t) {
int n = size(s);
set<ii> st;
for (int i = 0; i < n; ++i)
st.insert({t[i], s[i]});
for (int prv = 1e9; !st.empty();)
{
auto it = st.lower_bound(mp(prv, 1e9));
if (it == st.begin())
return 1;
it = prev(it);
prv = (it -> s2);
st.erase(it);
}
return 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... |