#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()) {
stop_times.insert({{time + disdiff*slope, slope}, id});
}
else {
stop_times.insert({{stop_times.upper_bound({time + disdiff*slope, slope})->first.first, slope}, id});
}
}
std::swap(start_time, stop_times);
}
for (auto [ab, id] : start_time) {
auto [time, slope] = ab;
if (id == n) {
return time;
}
}
return 0;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |