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;
#define int long long
const int mxN = 1007;
int n, len, x, m, y, t[mxN][mxN], e[mxN][mxN], gt[mxN][mxN], pref[mxN][mxN];
vector<int> s, vec;
vector<pair<int,int>> arr;
int cur_ind;
bool cmp(int a, int b) {
if (t[a][cur_ind] == t[b][cur_ind]) {
return arr[a].second < arr[b].second;
}
return t[a][cur_ind] < t[b][cur_ind];
}
void init(int32_t L, int32_t N, std::vector<long long> T, std::vector<int32_t> W, int32_t X, int32_t M, std::vector<int32_t> S)
{
n = N, len = L, m = M, x = X;
vector<int> inds;
for (int i = 0; i < n; ++i) {
arr.push_back({T[i], W[i]});
vec.push_back(T[i]);
inds.push_back(i);
}
sort(arr.begin(), arr.end());
sort(vec.begin(), vec.end());
for (int i = 0; i < n; ++i) {
t[i][0] = arr[i].first;
}
for (int i = 0; i < m; ++i) {
s.push_back(S[i]);
}
for (int j = 1; j < m; ++j) {
for (int i = 0; i < n; ++i) {
e[i][j] = t[i][j - 1] + arr[i].second * (s[j] - s[j - 1]);
}
cur_ind = j - 1;
sort(inds.begin(), inds.end(), cmp);
int mx = 0;
for (auto i : inds) {
mx = max(mx, e[i][j]);
t[i][j] = mx;
}
}
}
long long arrival_time(long long Y)
{
y = Y;
t[n][0] = y;
for (int j = 1; j < m; ++j) {
e[n][j] = t[n][j - 1] + x * (s[j] - s[j - 1]);
t[n][j] = e[n][j];
for (int i = 0; i < n; ++i) {
if (t[i][j - 1] < t[n][j - 1]) {
t[n][j] = max(t[n][j], e[i][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... |