Submission #492053

#TimeUsernameProblemLanguageResultExecution timeMemory
492053VirvRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
43 ms3524 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...