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;
const long long inf = 1e18;
long long plan_roller_coaster(vector <int> s, vector <int> t)
{
int n = (int)s.size();
long long ans = inf;
for (int i = 0; i < n; i++)
{
multiset <pair <int, int> > se;
for (int j = 0; j < n; j++)
if (j != i)
se.insert({s[j], t[j]});
long long curr_ans = 0;
int curr_t = t[i];
while (!s.empty())
{
auto it = se.lower_bound({curr_t, 0});
if (it == se.end())
it--;
curr_ans += max(0, curr_t - it->first);
curr_t = it->second;
se.erase(it);
}
ans = min(ans, curr_ans);
}
return ans;
}
# | 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... |