This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
struct Bus {
ll start, speed, arrive;
};
ll l, n, x, m;
vector<ll> s;
vector<Bus> a;
bool srt(Bus a, Bus b) {
return a.start < b.start;
}
void init(int el, int en, vector<ll> t, vector<int> w, int ex, int em, vector<int> es) {
l = el, n = en, x = ex, m = em;
a = vector<Bus>(n);
for(int i = 0; i < m; i++) s[i] = es[i];
for(ll i = 0; i < n; i++) {
a[i].start = t[i];
a[i].speed = w[i];
}
sort(a.begin(), a.end(), srt);
for(ll i = 0; i < n; i++) {
a[i].arrive = max(a[i].start+a[i].speed*l, (i == 0 ? 0 : a[i-1].arrive));
//cout << a[i].start << " " << a[i].speed << " " << a[i].arrive << "\n";
}
}
ll arrival_time(ll y) {
if(y <= a[0].start) return y+x*l;
else {
for(ll i = 0; i < m; i++) {
if(y+x*s[i] <= a[0].start+a[0].speed*s[i]) return a[0].start+a[0].speed*s[i] + x*(l-s[i]);
if(i == m-1) return y+x*l;
}
}
}
Compilation message (stderr)
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
40 | }
| ^
# | 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... |