summaryrefslogtreecommitdiff
path: root/datastructures/monotonicConvexHull.cpp
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 01:24:14 +0100
committerGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 01:24:14 +0100
commit98567ec798aa8ca2cfbcb85c774dd470f30e30d4 (patch)
tree5113d5cc24d1ad5f93810b6442ce584a36950dc8 /datastructures/monotonicConvexHull.cpp
parentad3856a6b766087df0036de0b556f4700a6498c9 (diff)
parent8d11c6c8213f46f0fa19826917c255edd5d43cb1 (diff)
mzuenni tests
Diffstat (limited to 'datastructures/monotonicConvexHull.cpp')
-rw-r--r--datastructures/monotonicConvexHull.cpp26
1 files changed, 0 insertions, 26 deletions
diff --git a/datastructures/monotonicConvexHull.cpp b/datastructures/monotonicConvexHull.cpp
deleted file mode 100644
index e7b9b3e..0000000
--- a/datastructures/monotonicConvexHull.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-struct Envelope {
- struct Line {
- ll m, b;
- ll operator()(ll x) { return m*x+b; }
- };
-
- vector<Line> ls;
- int ptr = 0;
-
- static bool bad(Line l1, Line l2, Line l3) {
- return (l3.b-l1.b)*(l1.m-l2.m) < (l2.b-l1.b)*(l1.m-l3.m);
- }
-
- void add(ll m, ll b) {
- while (sz(ls) > 1 && bad(ls.end()[-2], ls.back(), {m, b})) {
- ls.pop_back();
- }
- ls.push_back({m, b});
- ptr = min(ptr, sz(ls) - 1);
- }
-
- ll query(ll x) {
- while (ptr < sz(ls)-1 && ls[ptr + 1](x) < ls[ptr](x)) ptr++;
- return ls[ptr](x);
- }
-};