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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int l, n, x, m;
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; t = T; w = W; x = X; m = M; s = S;
return;
}
ll est[1010][1010], arr[1010][1010];
ll arrival_time(ll Y) {
for (int i = 0; i < n; i++) arr[0][i] = t[i];
arr[0][n] = Y;
for (int j = 1; j < m; j++) {
for (int i = 0; i < n; i++) est[j][i] = arr[j - 1][i] + (ll)w[i] * (s[j] - s[j - 1]);
est[j][n] = arr[j - 1][n] + (ll)x * (s[j] - s[j - 1]);
vector<pll> tlist;
for (int i = 0; i <= n; i++) tlist.push_back({arr[j - 1][i], i});
sort(tlist.begin(), tlist.end());
ll last = 0, p = 0;
for (int i = 0; i <= n; i++) {
arr[j][tlist[i].second] = max(last, est[j][tlist[i].second]);
last = max(last, est[j][tlist[i].second]);
}
}
return arr[m - 1][n];
}
Compilation message (stderr)
overtaking.cpp: In function 'll arrival_time(ll)':
overtaking.cpp:31:22: warning: unused variable 'p' [-Wunused-variable]
31 | ll last = 0, p = 0;
| ^
# | 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... |