# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200821 | maruii | Long Distance Coach (JOI17_coach) | C++14 | 75 ms | 117880 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;
using ll = long long;
using pii = pair<ll, ll>;
#define ff first
#define ss second
int N, M;
struct CHT {
struct Node {
pii L;
int l, r;
Node() : L(pii(0, 1e18)), l(-1), r(-1) {}
} A[5000005];
ll f(pii L, int x) { return L.ff * x + L.ss; }
int cnt;
void update(int nn, int s, int e, pii L2) {
pii &L1 = A[nn].L;
if (f(L1, s) > f(L2, s)) swap(L1, L2);
if (f(L1, e) <= f(L2, e)) return;
int m = s + e >> 1;
if (f(L1, m) > f(L2, m)) {
if (A[nn].l < 0) A[nn].l = ++cnt;
update(A[nn].l, s, m, L2);
}
else {
if (A[nn].r < 0) A[nn].r = ++cnt;
update(A[nn].r, m + 1, e, L2);
}
}
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... |