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 <algorithm>
#include <iostream>
#include <set>
#include <vector>
#include "railroad.h"
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int M = 0;
int a = 1e9;
for (size_t i{}; i < s.size(); ++i) {
M = std::max(M, t[i] - a);
a = std::min(a, s[i]);
}
a = 1e9;
for (size_t i = s.size(); i--;) {
M = std::max(M, t[i] - a);
a = std::min(a, s[i]);
}
long long R{};
for (size_t i{}; i < s.size(); ++i) {
auto x = std::max(0, t[i] - s[(i + 1) % s.size()]);
R += x;
// std::cerr << x << '\n';
}
// std::cerr << R << ' ' << M << '\n';
return R - M;
}
# | 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... |