# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1063838 | ProtonDecay314 | Overtaking (IOI23_overtaking) | C++17 | 0 ms | 0 KiB |
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 vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vpi> vvpi;
typedef vector<vpll> vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef short int si;
typedef vector<si> vsi;
typedef vector<vsi> vvsi;
#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define L(varll, mn, mx) for(ll varll = (mn); varll < (mx); varll++)
#define LR(varll, mx, mn) for(ll varll = (mx); varll > (mn); varll--)
#define LI(vari, mn, mx) for(int vari = (mn); vari < (mx); vari++)
#define LIR(vari, mx, mn) for(int vari = (mx); vari > (mn); vari--)
#define INPV(varvec) for(auto& varveci : (varvec)) cin >> varveci
#define fi first
#define se second
#define pb push_back
#define INF(type) numeric_limits<type>::max()
#define NINF(type) numeric_limits<type>::min()
#define TCASES int t; cin >> t; while(t--)
struct bus {
ll v;
ll t;
};
typedef vector<bus> vbu;
typedef vector<vbu> vvbu;
ll n;
vbu init_buses;
void init(int L, int N, vll T, vi W, int X, int M, vi S)
{
// ! No need to clear variables! This procedure is only called once :))
LI(i, 0, N) {
if(W[i] > X) {
init_buses.pb({W[i] - X, T[i]});
}
}
n = init_buses.size();
// Learning: vector assignment in C++
// implicitly calls the copy constructor
sort(init_buses.begin(), init_buses.end(), [](bus& b1, bus& b2) {return b1.t < b2.t || (b1.t == b2.t && b1.v < b2.v);});
return;
}
ll arrival_time(ll Y)
{
// for each bus whose arrival time is less than the current, get the maximum time
ll max_t = Y + X * S[1];
L(i, 0ll, n) {
if(init_buses[i].t < Y) {
max_t = max(max_t, init_buses[i].t + init_buses[i].v * S[1]);
}
}
return max_t;
}