# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1016715 | tmarcinkevicius | Overtaking (IOI23_overtaking) | C++17 | 0 ms | 0 KiB |
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 <bits/stdc++.h>
using namespace std;
#define int int64_t
void init(int32_t _L, int32_t _N, vector<int> _T, vector<int32_t> _W, int32_t _X, int32_t _M, vector<int32_t> _S);
long long arrival_time(long long Y);
vector<vector<int>> Expected, Real;
int32_t L;
int32_t N;
vector<int> T;
vector<int32_t> W;
int32_t X;
int32_t M;
vector<int32_t> S;
void init(int32_t _L, int32_t _N, vector<int> _T, vector<int32_t> _W, int32_t _X, int32_t _M, vector<int32_t> _S)
{
_W.push_back(_X);
L = _L;
N = _N;
T = _T;
W = _W;
X = _X;
M = _M;
S = _S;
return;
}
long long arrival_time(long long Y)
{
Expected = vector<vector<int>>(N + 1);
Real = vector<vector<int>>(N + 1);
T.push_back(Y);
for (int i = 0; i <= N; i++)
{
Expected[i] = vector<int>(M);
Real[i] = vector<int>(M);
Expected[i][0] = T[i];
Real[i][0] = T[i];
}
for (int i = 1; i < M; i++)
{
int dis = S[i] - S[i - 1];
for (int j = 0; j <= N; j++)
{
Expected[j][i] = Real[j][i - 1] + dis * W[j];
}
for (int j = 0; j <= N; j++)
{
Real[j][i] = Expected[j][i];
for (int z = 0; z <= N; z++)
{
if (z == j)
continue;
if (Real[z][i - 1] < Real[j][i - 1])
{
Real[j][i] = max(Real[j][i], Expected[z][i]);
}
}
}
}
/*for (int i = 0; i <= N; i++)
{
cout << "i = " << i << " ";
for (int j = 0; j < M; j++)
{
cout << "|e: " << setw(4) << Expected[i][j] << ", r: " << setw(4) << Real[i][j] << "| ";
}
cout << '\n';
}*/
T.pop_back();
return Real[N][M - 1];
}
/*int32_t main()
{
int _L, _N, _X, _M, _Q;
cin >> _L >> _N >> _X >> _M >> _Q;
vector<int> _T(_N);
for (int i = 0; i < _N; i++)
cin >> _T[i];
vector<int32_t> _W(_N);
for (int i = 0; i < _N; i++)
cin >> _W[i];
vector<int32_t> _S(_M);
for (int i = 0; i < _M; i++)
cin >> _S[i];
vector<int> _Y(_Q);
for (int i = 0; i < _Q; i++)
cin >> _Y[i];
init(_L, _N, _T, _W, _X, _M, _S);
vector<int> res(_Q);
for (int i = 0; i < _Q; i++)
res[i] = arrival_time(_Y[i]);
for (int i = 0; i < _Q; i++)
cout << res[i] << '\n';
}*/