# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
731810 | beaboss | Circus (Balkan15_CIRCUS) | C++14 | 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 "bits/stdc++.h"
using namespace std;
#define s second
#define f first
#define pb push_back
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
// const ll N = 100001;
deque<pii> vals;
void init(ll n, ll m, ll x[]){
vals.pb({m - 0, m});
for (ll i = n - 1; i>= 0; i--) {
auto it = lower_bound(vals.begin(), vals.end(), make_pair(x[i], -1ll)) - vals.begin();
// cout << x[i] << vals[it].s << (vals[it].s - x[i]) << endl;
vals.push_front({x[i] - (vals[it].s - x[i]), x[i]});
}
}
ll minLength(ll d) {
auto it = lower_bound(vals.begin(), vals.end(), make_pair(d, -1ll)) - vals.begin();
return vals[it].s - d;
}