summaryrefslogtreecommitdiff
path: root/content/datastructures/monotonicConvexHull.cpp
diff options
context:
space:
mode:
authormzuenni <michi.zuendorf@gmail.com>2024-08-17 20:30:08 +0200
committermzuenni <michi.zuendorf@gmail.com>2024-08-17 20:30:08 +0200
commitc31dcca8b822a38298c3dd624c3c1c0c23caa57d (patch)
tree70e73c0ae867ff61c7a0864a26f876ebe66147d0 /content/datastructures/monotonicConvexHull.cpp
parent915bbaea690d3d352b06d5a2660166de7fd9cd21 (diff)
improved monotonic onvex hull
Diffstat (limited to 'content/datastructures/monotonicConvexHull.cpp')
-rw-r--r--content/datastructures/monotonicConvexHull.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/content/datastructures/monotonicConvexHull.cpp b/content/datastructures/monotonicConvexHull.cpp
index e84ad86..f1721ae 100644
--- a/content/datastructures/monotonicConvexHull.cpp
+++ b/content/datastructures/monotonicConvexHull.cpp
@@ -1,5 +1,5 @@
// Min über Geraden mit MONOTONEN Inserts UND Queries. Jede neue
-// Gerade hat kleinere Steigung als alle vorherigen.
+// Gerade hat kleineres pair(m, c) als alle vorherigen.
struct Line {
ll m, c;
ll operator()(ll x) {return m*x+c;}
@@ -20,7 +20,7 @@ void add(ll m, ll c) { // m fallend, Laufzeit O(1) amortisiert
ptr = min(ptr, sz(ls) - 1);
}
-ll query(ll x) { // x steigend, Laufzeit: O(1) amortisiert
+ll query(ll x) { // x >= letztes x, Laufzeit: O(1) amortisiert
ptr = min(ptr, sz(ls) - 1);
while (ptr + 1 < sz(ls) && ls[ptr + 1](x) < ls[ptr](x)) ptr++;
return ls[ptr](x);