Convert x - c >= 0 to x >= c since the former will be faster (https://godbolt.org/z/cB0bJm)
This commit is contained in:
parent
068325b6fa
commit
6a8019e2ca
|
@ -247,7 +247,7 @@ value[0] = 0;
|
|||
for (int x = 1; x <= n; x++) {
|
||||
value[x] = INF;
|
||||
for (auto c : coins) {
|
||||
if (x-c >= 0) {
|
||||
if (x >= c) {
|
||||
value[x] = min(value[x], value[x-c]+1);
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ value[0] = 0;
|
|||
for (int x = 1; x <= n; x++) {
|
||||
value[x] = INF;
|
||||
for (auto c : coins) {
|
||||
if (x-c >= 0 && value[x-c]+1 < value[x]) {
|
||||
if ((x >= c) && value[x-c]+1 < value[x]) {
|
||||
value[x] = value[x-c]+1;
|
||||
first[x] = c;
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ for $0 \le x \le n$:
|
|||
count[0] = 1;
|
||||
for (int x = 1; x <= n; x++) {
|
||||
for (auto c : coins) {
|
||||
if (x-c >= 0) {
|
||||
if (x >= c) {
|
||||
count[x] += count[x-c];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue