summaryrefslogtreecommitdiff
path: root/datastructures/monotonicConvexHull.cpp
diff options
context:
space:
mode:
authorPaul Jungeblut <paul.jungeblut@gmail.com>2018-01-03 17:06:36 +0100
committerPaul Jungeblut <paul.jungeblut@gmail.com>2018-01-03 17:06:36 +0100
commit025b4a5abd77a705c313aee0b8d329fed4f47c42 (patch)
tree65a713e3db21602172150045af8e8cc4100eadc5 /datastructures/monotonicConvexHull.cpp
parent412e5011becbbc52864fe8764626498a2ad87647 (diff)
Fixing two errors in convex hull optimization code.
Diffstat (limited to 'datastructures/monotonicConvexHull.cpp')
-rw-r--r--datastructures/monotonicConvexHull.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/datastructures/monotonicConvexHull.cpp b/datastructures/monotonicConvexHull.cpp
index a93bfae..64af841 100644
--- a/datastructures/monotonicConvexHull.cpp
+++ b/datastructures/monotonicConvexHull.cpp
@@ -10,7 +10,9 @@ void add(ll m, ll b) { // Laufzeit O(1) amortisiert
ms.push_back(m); bs.push_back(b);
while (ms.size() >= 3 && bad(ms.size() - 3, ms.size() - 2, ms.size() - 1)) {
ms.erase(ms.end() - 2); bs.erase(bs.end() - 2);
-}}
+ }
+ ptr = min(ptr, ms.size() - 1);
+}
ll get(int idx, ll x) { return ms[idx] * x + bs[idx]; }