#include "overtaking.h"
#include <iostream>
using namespace std;
bool debug=0;
#define ll long long
#define pb push_back
#define mp make_pair
#define derr if(debug)cerr
#define dlist(x) if(debug){cerr<<"dlist "<<#x<<":\n";for(auto e:x){cerr<<e<<" ";}cerr<<"\n";}
ll n,l,x,m;
vector<ll> t,w,s;
vector<ll> arrival_times; // times that bus 0 arrives at i-th sorting station...
void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S){
// L,N : length of road, number of busses
// T: array for the times at which the non-reserve busses leave the airport.
// W: speeds of the busses (time to travel 1km)
// X: speed of the reserve bus (time to travel 1km)
// M: how many sorting stations there are
// S: distances of the sorting stations from the airport.
l=L;
n=N;
for(ll e:T){
t.pb(e);
}
for(ll e:W){
w.pb(e);
}
x=X;
m=M;
for(ll e:S){
s.pb(e);
}
// 2<=M because i=0 and i=L-1 are both technically sorting stations.
for(int i=0; i<M; i++){
arrival_times.pb(T[0] + S[i]*W[0]);
}
dlist(arrival_times);
return;
}
// the below procedure is called exactly Q times...
ll arrival_time(ll Y){
derr<<"\t testcase...\n";
// Y = the time at which the reserve bus leaves
// >--- subtask 1: N=1 ---<
ll buffer = Y;
bool is_infront = (Y<=arrival_times[0]);
if(x > w[0]){ // if the reserve bus is actually *slower*
return buffer+l*x;
}
derr<<(is_infront ? "it's infront!\n" : "it's behind!\n");
for(int i=1; i<m; i++){
if(is_infront)break;
else if(buffer + s[i]*x <= arrival_times[i]){
buffer = arrival_times[i]-s[i]*x;
is_infront=true;
}
}
return buffer + l*x;
}
# | 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... |