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 || 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)
overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:23:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
23 | for (int x : W) w.pb(x); for (int x : T) t.pb(x); for (int x : S) s.pb(x);
| ^~~
overtaking.cpp:23:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
23 | for (int x : W) w.pb(x); for (int x : T) t.pb(x); for (int x : S) s.pb(x);
| ^~~
overtaking.cpp:32:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int j = 0; j < v[i].size(); j++)
| ~~^~~~~~~~~~~~~
# | 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... |