이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |