OSDN Git Service
(root)
/
oi-wiki
/
main.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c8b8e27
)
修正最长不下降子序列nlogn解法的代码错误
author
LincolnYe
<48617718+LincolnYe@users.noreply.github.com>
Tue, 22 Sep 2020 04:18:04 +0000
(12:18 +0800)
committer
GitHub
<noreply@github.com>
Tue, 22 Sep 2020 04:18:04 +0000
(12:18 +0800)
如该解法中代码上面的算法描述,在dp中找到第一个大于a[i]的元素,则应该使用upper_bound,而不是lower_bound。
docs/dp/basic.md
patch
|
blob
|
history
diff --git
a/docs/dp/basic.md
b/docs/dp/basic.md
index
0a4bf77
..
f4371d8
100644
(file)
--- a/
docs/dp/basic.md
+++ b/
docs/dp/basic.md
@@
-160,7
+160,7
@@
for (int i = 0; i < n; ++i) scanf("%d", a + i);
memset(dp, 0x1f, sizeof dp);
mx = dp[0];
for (int i = 0; i < n; ++i) {
- *std::
low
er_bound(dp, dp + n, a[i]) = a[i];
+ *std::
upp
er_bound(dp, dp + n, a[i]) = a[i];
}
ans = 0;
while (dp[ans] != mx) ++ans;