Submission #1247062

#TimeUsernameProblemLanguageResultExecution timeMemory
1247062linusvdvOvertaking (IOI23_overtaking)C++20
39 / 100
3594 ms560 KiB
#include "overtaking.h" #include <map> #include <vector> int l, n, m, x; std::vector<long long> t; std::vector<int> w; std::vector<int> s; void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S) { l = L; n = N; m = M; x = X; t = T; w = W; s = S; } long long arrival_time(long long Y) { // time, speed, id std::map<std::pair<long long, int>, int> start_time; for (int i = 0; i < n; i++) { if (w[i] <= x) continue; start_time.insert({{t[i], w[i]}, i}); } // reserve bus start_time.insert({{Y, x}, n}); // go over bussesstops for (int i = 1; i < m; i++) { long long disdiff = s[i] - s[i-1]; std::map<std::pair<long long, int>, int> stop_times; for (auto [ab, id] : start_time) { auto [time, slope] = ab; if (stop_times.upper_bound({time + disdiff*slope, slope}) == stop_times.end()) { long long idx = time + disdiff*slope; stop_times[{idx, slope}] = std::max(id, stop_times[{idx, slope}]); } else { long long idx = stop_times.rbegin()->first.first; stop_times[{idx, slope}] = std::max(id, stop_times[{idx, slope}]); } } std::swap(start_time, stop_times); } for (auto [ab, id] : start_time) { auto [time, slope] = ab; if (id == n) { return time; } } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...