이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int N = 200005;
struct ban
{
int s, t;
};
int n;
ban a[N];
bool operator<(const ban& a, const ban& b)
{
if (a.s < b.s)
return true;
if (a.s > b.s)
return false;
return a.t < b.t;
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t)
{
n = sz(s);
for (int i = 1; i <= n; ++i)
{
a[i].s = s[i - 1];
a[i].t = t[i - 1];
}
sort(a + 1, a + n + 1);
ll ans = 0;
for (int i = 1; i < n; ++i)
{
ans += max(0, a[i].t - a[i + 1].s);
}
do
{
ll yans = 0;
for (int i = 1; i < n; ++i)
{
yans += max(0, a[i].t - a[i + 1].s);
}
ans = min(ans, yans);
} while (next_permutation(a + 1, a + n + 1));
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... |