# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061231 | aykhn | Overtaking (IOI23_overtaking) | C++17 | 1 ms | 348 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 pair<ll, ll> pii;
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define mxn (ll)(1e3 + 5)
ll n, m, l, x;
vector<ll> w, t, s;
vector<pii> v[mxn];
vector<pii> ran[mxn];
vector<ll> pref[mxn];
void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S)
{
n = N, m = M, l = L, x = X;
for (int x : W) w.pb(x); for (int x : T) t.pb(x); for (int x : S) s.pb(x);
for (int i = 0; i < n; i++) v[0].pb({t[i], w[i]});
for (int i = 0; i + 1 < m; i++)
{
sort(v[i].begin(), v[i].end(), [&](const pii &a, const pii &b)
{
if (a.fi == b.fi) return a.se < b.se;
return a.fi < b.fi;
});
for (int j = 0; j < v[i].size(); j++)
{
if (!j || pref[i][j - 1] <= v[i][j].fi + (s[i + 1] - s[i]) * v[i][j].se)
{
v[i + 1].pb({v[i][j].fi + (s[i + 1] - s[i]) * v[i][j].se, v[i][j].se});
ran[i].pb({v[i][j].fi, v[i][j].fi + (s[i + 1] - s[i]) * v[i][j].se});
pref[i].pb(v[i][j].fi + (s[i + 1] - s[i]) * v[i][j].se);
continue;
}
v[i + 1].pb({pref[i][j - 1], v[i][j].se});
pref[i].pb(pref[i][j - 1]);
}
}
}
ll arrival_time(ll Y)
{
ll cur = Y;
for (int i = 0; i + 1 < m; i++)
{
int ind = lower_bound(ran[i].begin(), ran[i].end(), mpr(cur, cur + (s[i + 1] - s[i]) * x)) - ran[i].begin() - 1;
if (ind < 0 || ind >= ran[i].size() || ran[i][ind].se <= cur + (s[i + 1] - s[i]) * x)
{
cur = cur + (s[i + 1] - s[i]) * x;
continue;
}
cur = ran[i][ind].se;
}
return cur;
}
Compilation message (stderr)
# | 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... |