This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* Ignut
started: 14.08.2024
now: 14.08.2024
████████████████████████████████████████████████████████████████████
████████████████████████████████ ████████████████████████████████
██████████████████████████████ ██████████████████████████████
██████ ██████████████████ ██████████████████ ██████
██████ ██████████████ ██████████████ ██████
██████ ██ ████████████ ████████████ ██ ██████
██████ ████ ██████████ ██████████ ████ ██████
██████ ████ ██████████ ██████████ ████ ██████
██████ ████ ██████████ ██████████ ██████ ██████
██████ ██████ ██████████ ██████████ ██████ ██████
██████ ██████ ████████ ████████ ██████ ██████
██████ ██████ ██████ ██████ ██████ ██████
██████ ████ ████ ████ ████ ██████
██████ ██████████ ████ ██████████ ██████
██████ ██ ██████ ████████ ██████ ██ ██████
██████ ██████ ████████ ██████ ██████
██████ ██ ██ ██████
██████████████████████ ████ ████ ██████████████████████
████████████████████████ ██ ██ ████████████████████████
██████████████████████████ ██████████████████████████
██████████████████████████████ ██████████████████████████████
████████████████████████████████████████████████████████████████████
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int l;
int n, m;
vector<ll> t;
vector<int> w;
vector<int> s;
int x;
// <time, speed, next_time>
vector<vector<tuple<ll, int, ll>>> vec;
void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S) {
l = L; n = N; m = M; w = W; s = S; x = X; t = T;
// <tm, speed>
vector<pair<ll, int>> v;
for (int i = 0; i < n; i ++) if (w[i] > x) v.push_back({t[i], w[i]});
sort(v.begin(), v.end());
for (int i = 1; i < m; i ++) {
vector<pair<ll, int>> next;
vector<tuple<ll, int, ll>> add;
ll maxTime = 0;
for (auto [tm, sp] : v) {
ll e = tm + 1ll * (s[i] - s[i - 1]) * sp;
next.push_back({max(e, maxTime), sp});
maxTime = max(e, maxTime);
add.push_back({tm, sp, maxTime});
}
vec.push_back(add);
v = next;
sort(v.begin(), v.end());
}
}
ll arrival_time(ll Y) {
ll tm = Y, sp = x;
for (int i = 1; i < m; i ++) {
int lo = 0, hi = n - 1;
while (lo < hi) {
int mid = lo + (hi - lo + 1) / 2;
if (get<0>(vec[i - 1][mid]) < tm)
lo = mid;
else
hi = mid - 1;
}
ll mx = tm + 1ll * (s[i] - s[i - 1]) * sp;
if (get<0>(vec[i - 1][lo]) < tm) {
mx = max(mx, get<2>(vec[i - 1][lo]));
}
tm = mx;
}
return tm;
}
# | 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... |