#include "overtaking.h"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define siz(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace std;
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;
ll L;
int n,m;
ll T[1001];
ll W[1001];
ll S[1001];
ll arr_time[1001][1001];
ll X;
void init(int L2, int N2, vl T2, vi W2, int X2, int M2, vi S2)
{
L = L2;
n = N2;
rep(i,n) T[i] = T2[i];
rep(i,n) W[i] = W2[i];
X = X2;
m = M2;
rep(i,m) S[i] = S2[i];
vector<pll> bus;
rep(i,n) if(W[i] > X) bus.pb({W[i],T[i]});
sort(all(bus));
reverse(all(bus));
n = 0;
forall(it,bus)
{
W[n] = it.ff;
T[n] = it.ss;
n++;
}
rep(i,n)
{
arr_time[i][0] = T[i];
}
rep2(j,1,m-1)
{
vector<pii> arrs;
rep(i,n) arrs.pb({arr_time[i][j-1],-i});
sort(all(arrs));
ll max_time = 0;
forall(it,arrs)
{
int i = -it.ss;
arr_time[i][j] = max(arr_time[i][j-1] + (S[j]-S[j-1]) * W[i],max_time);
max_time = max(max_time,arr_time[i][j]);
}
}
return;
}
ll arrival_time(ll time_)
{
rep(j,m-1)
{
ll max_ = -1e18;
rep(i,n)
{
if(arr_time[i][j] < time_)
{
max_ = max(max_,arr_time[i][j+1]);
}
}
if(max_ <= time_ + X*(S[j+1]-S[j]))
{
time_ += X * (S[j+1]-S[j]);
}
else
{
time_ = max_;
}
}
return time_;
}
# | 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... |