#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> start; // start time of each bus
vector<int> speed;//bus speed
vector<int> stops;
int len; // size of road
int n, m; // number of buses and stations
int xsp; // reserve travel time
void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S) {
len = L;
n = N;
start = T;
speed = W;
xsp = X;
m = M;
stops = S;
}
ll arrival_time(ll st) {
vector<tuple<ll, int, bool>> currTimes;
for (int i = 0; i < n; i++) {
currTimes.push_back({start[i], speed[i], false});
}
currTimes.push_back({st, xsp, true});
for (int i = 0; i < m-1; i++) {
sort(currTimes.begin(), currTimes.end());
vector<tuple<ll, int, bool>> nxt;
ll maxTime = -1;
int dis = stops[i+1] - stops[i];
for (auto [currTime, sp, special]: currTimes) {
ll nxtTime = currTime + sp * dis;
nxtTime = max(nxtTime, maxTime);
maxTime = max(maxTime, nxtTime);
nxt.push_back({nxtTime, sp, special});
}
currTimes = nxt;
}
for (auto [a, b, c]: currTimes) {
if (c == true) {
return a;
}
}
}
Compilation message (stderr)
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:49:1: warning: control reaches end of non-void function [-Wreturn-type]
49 | }
| ^
# | 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... |