#include <bits/stdc++.h>
#include "overtaking.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
#define pb push_back
#define ff first
#define ss second
int n, m, l, x;
vector<ll> t;
vector<int> w, s;
void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S){
l = L; n = N; x = X; m = M;
t = T; w = W; s = S;
t.resize(n + 1);
w.resize(n + 1); w[n] = X;
}
ll arrival_time(ll y){
vector<vector<ll>> e(n + 1, vector<ll>(m)), T = e;
t[n] = y;
for (int i = 0; i <= n; i++) T[i][0] = t[i];
for (int j = 1; j < m; j++){
for (int i = 0; i <= n; i++){
e[i][j] = T[i][j - 1] + 1LL * w[i] * (s[j] - s[j - 1]);
}
vector<pli> all;
for (int i = 0; i <= n; i++){
all.pb({T[i][j - 1], i});
}
sort(all.begin(), all.end());
int k = 0; ll mx = 0;
for (int i = 0; i <= n; i++){
while (k < i && all[k].ff < all[i].ff){
mx = max(mx, e[all[k].ss][j]);
k++;
}
T[all[i].ss][j] = max(mx, e[all[i].ss][j]);
}
}
return T[n][m - 1];
}
# | 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... |