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 <vector>
#include <algorithm>
class name {
public:
int value;
int pos;
bool operator<(const name& b) const {
return value < b.value;
}
} put_in;
std::vector<name> h;
std::vector<name> g;
bool check[100005];
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
long long ans = 0;
int N = (int) s.size();
for (int q = 0; q < N; q++) {
put_in.value = s[q];
put_in.pos = q;
h.push_back(put_in);
}
for (int q = 0; q < N; q++) {
put_in.value = t[q];
put_in.pos = q;
g.push_back(put_in);
}
std::sort(h.begin(), h.end());
std::sort(g.begin(), g.end());
g.erase(g.end());
for (int q = 0; q < N - 1; q++) {
if (h.back().pos != g.back().pos) {
if (h.back().value < g.back().value) {
ans += g.back().value - h.back().value;
}
h.erase(h.end());
g.erase(g.end());
}
else {
if (h[h.size() - 2].value < g.back().value) {
ans += g.back().value - h[h.size() - 2].value;
}
h.erase(h.end() - 1);
g.erase(g.end());
}
}
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... |