# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
35633 | szawinis | Building Bridges (CEOI17_building) | C++14 | 189 ms | 13900 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;
typedef long long ll;
const ll MOD = (1e9)+7, INF = 1e18;
const int MAX = (1e5)+1;
struct line {
ll m, c;
mutable function<const line*()> succ;
ll getVal(ll x) { return m*x + c; }
bool operator<(const line& rhs) const {
if(rhs.c != -INF) return m > rhs.m;
const line* s = succ();
if(!s) return false;
return ((double) c - s->c > (double) (s->m - m)*rhs.m);
}
};
class MinHull : public multiset<line> {
bool bad(iterator it) {
auto nxt = next(it);
if(it == begin()) {
if(nxt != end()) return nxt->m == it->m && nxt->c <= it->c;
else return false;
}
auto pre = prev(it);
if(nxt == end()) return pre->m == it->m && pre->c <= it->c;
line l1 = *pre, l2 = *it, l3 = *nxt;
return (double) (l3.c-l1.c)*(l1.m-l2.m) <= (double) (l2.c-l1.c)*(l1.m-l3.m);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |