Submission #1016732

#TimeUsernameProblemLanguageResultExecution timeMemory
1016732tmarcinkeviciusOvertaking (IOI23_overtaking)C++17
39 / 100
3545 ms16228 KiB
#include <bits/stdc++.h> #include "overtaking.h" using namespace std; //void init(int32_t _L, int32_t _N, vector<int64_t> _T, vector<int32_t> _W, int32_t _X, int32_t _M, vector<int32_t> _S); //long long arrival_time(long long Y); vector<vector<int64_t>> Expected, Real; int _L; int _N; vector<long long> _T; vector<int> _W; int _X; int _M; vector<int> _S; void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> 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<int64_t>>(_N + 1); Real = vector<vector<int64_t>>(_N + 1); _T.push_back(Y); for (int i = 0; i <= _N; i++) { Expected[i] = vector<int64_t>(_M); Real[i] = vector<int64_t>(_M); Expected[i][0] = _T[i]; Real[i][0] = _T[i]; } for (int i = 1; i < _M; i++) { long long 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<int64_t> 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'; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...