#include "overtaking.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> starts, speeds, stations;
vector<vector<ll>> expected;
ll length, n, m, speed;
void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S)
{
length = L;
n = N;
m = M;
starts = T;
for (auto &i : W) speeds.push_back(i);
for (auto &i : S) stations.push_back(i);
speed = X;
expected.push_back({});
expected[0].resize(m, 0);
expected[0][0] = starts[0];
for (int i = 1; i < m; ++i) {
expected[0][i] = expected[0][i - 1] + (stations[i] - stations[i - 1]) * speeds[0];
}
}
long long arrival_time(long long Y)
{
if (speed >= speeds[0] || Y <= starts[0]) return (Y + speed * length);
ll cur = Y;
for (int i = 1; i < m; ++i) {
cur += (stations[i] - stations[i - 1]) * speed;
if (cur <= expected[0][i]) {
return (expected[0][i] + speed * (stations[m - 1] - stations[i]));
}
}
return cur;
}
# | 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... |