Submission #1119254

#TimeUsernameProblemLanguageResultExecution timeMemory
1119254blackslexOvertaking (IOI23_overtaking)C++17
65 / 100
3532 ms79080 KiB
#include "overtaking.h" #include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; const int N = 1005; ll l, n, m, x; vector<ll> w, s; vector<ll> t; vector<vector<ll>> e, ct; multiset<pii> ms[N]; void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S){ l = L; n = N; t = T; x = X; m = M; w.resize(n); s.resize(m); for (int i = 0; i < n; i++) w[i] = W[i]; for (int i = 0; i < m; i++) s[i] = S[i]; e = vector<vector<ll>>(n, vector<ll>(m)); ct = vector<vector<ll>>(n, vector<ll>(m)); for (int i = 0; i < n; i++) ct[i][0] = t[i]; for (int j = 1; j < m; j++) { map<ll, vector<ll>> mp; ll cmx = 0; for (int i = 0; i < n; i++) { e[i][j] = ct[i][j - 1] + w[i] * (s[j] - s[j - 1]); mp[ct[i][j - 1]].emplace_back(i); } for (auto &[x, y]: mp) { for (auto &E: y) ct[E][j] = max(e[E][j], cmx); for (auto &E: y) cmx = max(cmx, e[E][j]); } } for (int j = 1; j < m; j++) { map<ll, vector<ll>> mp; ll cmx = 0; for (int i = 0; i < n; i++) { mp[ct[i][j - 1]].emplace_back(i); } for (auto &[x, y]: mp) { for (auto &E: y) cmx = max(cmx, e[E][j]); ms[j].emplace(x, cmx); } } return; } long long arrival_time(long long Y){ ll cur = Y; for (int j = 1; j < m; j++) { ll nval = cur + x * (s[j] - s[j - 1]); auto it = ms[j].lower_bound({cur, 0}); if (it != ms[j].begin()) { it--; nval = max(nval, it->second); } cur = nval; } return cur; }
#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...