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>
const int N = 1111;
ll v1[N][N], v3[N][N];
int v2[N][N];
int sz;
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());
    sz = v.size();
    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});
        }
        for (int j = 0; j < sz; j ++) {
            v1[i - 1][j] = get<0>(add[j]);
            v2[i - 1][j] = get<1>(add[j]);
            v3[i - 1][j] = get<2>(add[j]);
        }
        v = next;
        sort(v.begin(), v.end());
    }
}
ll arrival_time(ll Y) {
    ll tm = Y, sp = x;
    int pos = sz - 1;
    for (int i = 1; i < m; i ++) {
        while (pos > 0 && v1[i - 1][pos] >= tm) pos --;
        int lo = pos;
        ll mx = tm + 1ll * (s[i] - s[i - 1]) * sp;
        if (lo < sz && v1[i - 1][lo] < tm) {
            mx = max(mx, v3[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... |