Submission #422362

#TimeUsernameProblemLanguageResultExecution timeMemory
422362TheWilpRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
104 ms19204 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...