This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "overtaking.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll NN = 2e5 + 5;
ll n, m, x;
ll a[NN], b[NN], jar[NN], sam[NN];
void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S)
{
    n = N;
    m = M;
    x = X;
    for(ll i = 0; i < n; i++)
    {
        a[i] = T[i];
        b[i] = W[i];
        // cout << a[i] << "dan" << b[i] << "ui\n";
    }
    for(ll i = 0; i < m; i++)
        jar[i] = S[i];
    return;
}
long long arrival_time(long long Y)
{
    a[n] = Y;
    b[n] = x;
    for(ll i = 0; i <= n; i++)
        sam[i] = a[i];
    for(ll i = 1; i < m; i++)
    {
        vector<pair<ll, pll> > v;
        for(ll j = 0; j <= n; j++)
        {
            // cout << j << "   " << b[j] << "U\n";
            v.pb(mp(sam[j], mp(b[j], j)));
        }
        sort(v.begin(), v.end());
        ll lst = 0;
        for(auto z : v)
        {
            // cout << "(" << i << "," << z.fi << ") " << sam[z.se.se] << " + " << (jar[i] - jar[i - 1]) << "*" << z.se.fi << "@\n";
            sam[z.se.se] = max(lst, sam[z.se.se] + (jar[i] - jar[i - 1]) * z.se.fi);
            lst = sam[z.se.se];
        }
    }
    return sam[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... |