Unverified Commit c1151586 authored by LincolnYe's avatar LincolnYe Committed by GitHub
Browse files

修正最长不下降子序列nlogn解法的代码错误

如该解法中代码上面的算法描述,在dp中找到第一个大于a[i]的元素,则应该使用upper_bound,而不是lower_bound。
parent c8b8e277
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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::lower_bound(dp, dp + n, a[i]) = a[i];
  *std::upper_bound(dp, dp + n, a[i]) = a[i];
}
ans = 0;
while (dp[ans] != mx) ++ans;