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 "overtaking.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using vi = vector <int>;
const ll MAXN = 1E3+16;
ll l, n, x, m;
vll t;
vi w, s;
// bus i moves 1 km in w[i] s/km
void init (int L, int N, vll T, vi W, int X, int M, vi S) {
l = L; n = N; x = X; m = M;
t = T;
w = W; s = S;
w.push_back(X);
}
ll arrival_time (ll y) {
vll ts = t;
ts.push_back(y);
for (ll i = 1; i < m; i++) {
ll dis = s[i]-s[i-1];
vll e(n+1);
for (ll j = 0; j <= n; j++) {
e[j] = ts[j] + dis*w[j];
}
vll nt(n+1);
for (ll j = 0; j <= n; j++) {
nt[j] = e[j];
for (ll k = 0; k <= n; k++) {
if (ts[k] < ts[j]) nt[j] = max(nt[j], e[k]);
}
}
ts = nt;
}
return ts[n];
}
# | 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... |