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;
typedef long long ll;
typedef pair<int,int> pii;
ll INF = 2e9;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
vector<pii> order;
for (int i = 0; i < n; ++i) {
order.push_back({t[i], -1});
order.push_back({s[i], 1});
}
order.push_back({INF, 1});
order.push_back({1, -1});
sort(order.begin(), order.end());
reverse(order.begin(), order.end());
ll d = 0, ans = 0;
for (pii p: order) {
if (p.second == 1) {
if (d < 0) ans -= p.first;
d++;
}
if (p.second == -1) {
if (d <= 0) ans += p.first;
d--;
}
}
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... |