Skip to content

Commit

Permalink
Optimize min_plus_conv
Browse files Browse the repository at this point in the history
  • Loading branch information
koba-e964 committed Apr 18, 2024
1 parent c2acca7 commit 263ce45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions atcoder/abc348/g.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ fn min_plus_conv(a: &[i64], b: &[i64]) -> Vec<i64> {
}
let mut dp = vec![INF; n + m - 1];
let cost_fun = |j: usize, i: usize| {
if i >= j && j < n && i < j + m {
a[j] + b[i - j]
if i >= j && i < j + m {
b[i - j]
} else {
INF / 2
}
};
monotone_minima(0, n, 0, n + m - 1, &vec![0; n], &mut dp, &cost_fun);
monotone_minima(0, n, 0, n + m - 1, &a, &mut dp, &cost_fun);
dp
}

Expand Down
6 changes: 3 additions & 3 deletions judge.yosupo.jp/min_plus_convolution_convex_arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ fn min_plus_conv(a: &[i64], b: &[i64]) -> Vec<i64> {
}
let mut dp = vec![INF; n + m - 1];
let cost_fun = |j: usize, i: usize| {
if i >= j && j < n && i < j + m {
a[j] + b[i - j]
if i >= j && i < j + m {
b[i - j]
} else {
INF / 2
}
};
monotone_minima(0, n, 0, n + m - 1, &vec![0; n], &mut dp, &cost_fun);
monotone_minima(0, n, 0, n + m - 1, &a, &mut dp, &cost_fun);
dp
}

Expand Down

0 comments on commit 263ce45

Please sign in to comment.