#include "overtaking.h"
#include <bits/stdc++.h> 
#pragma GCC optimize("O3,unroll-loops") 
#pragma GCC target("avx2") 
#define pb push_back
#define F first
#define pii pair<int,int> 
#define all(a) a.begin(),a.end()
#define S second 
#define sz(a) (int)a.size()
#define rep(i , a , b) for(int i = (a) ; i <= (b) ; i++)
#define per(i , a , b) for(int i = (a) ; i >= (b) ; i--)
#define ld double
#define ll long long 
using namespace std ;
const ll maxn = 1e5 + 10   , inf = 1e18 , mod = 998244353;
int n , l , m  ;
ll t[maxn] ;
int w[maxn] , s[maxn] ;
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 ;
    m = M ; 
    rep(i , 0 , n-1){
        t[i] = T[i] ;
        w[i] = W[i]; 
    }
    w[n] = X ;
    rep(i , 0, m-1){
        s[i] = S[i] ;
    }
    return;
}
ll ti[maxn]  , ti2[maxn ]; 
long long arrival_time(long long Y){
    t[n] = Y ; 
    rep(i , 0 ,n)ti[i] = t[i] ;
    rep(i , 1 , m-1){
        vector <pair<pii ,int> > vec2 ;
        rep(j , 0 ,n){
            ti2[j] = ti[j] + 1ll * (s[i]-s[i-1]) * w[j] ;
            vec2.pb({{ti[j],ti2[j]} , j});
        }
        sort(all(vec2)); 
        ll mn = -inf ;
        rep(j , 0 , sz(vec2)-1){
            int z = vec2[j].S ;
            ti[z] = max(mn , ti2[z]) ;
            mn = max(mn  , ti2[z]) ;
        }
    }
    return ti[n] ;
}
| # | 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... |