Skip to content

Commit 0a2f2fd

Browse files
Update Solution.java
1 parent b6c5f3a commit 0a2f2fd

File tree

1 file changed

+3
-3
lines changed
  • solution/3100-3199/3139.Minimum Cost to Equalize Array

1 file changed

+3
-3
lines changed

solution/3100-3199/3139.Minimum Cost to Equalize Array/Solution.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ public int minCostToEqualizeArray(int[] A, int c1, int c2) {
1717
long op2 = total - op1;
1818
long res = (op1 + op2 % 2) * c1 + op2 / 2 * c2;
1919

20-
total += op1 / (n - 2) * n;
21-
op1 %= n - 2;
20+
total += (op1 / (n - 2)) * n;
21+
op1 %= (n - 2);
2222
op2 = total - op1;
2323
res = Math.min(res, (op1 + op2 % 2) * c1 + op2 / 2 * c2);
2424

2525
for (int i = 0; i < 2; i++) {
2626
total += n;
27-
res = Math.min(res, total % 2 * c1 + total / 2 * c2);
27+
res = Math.min(res, (total % 2) * c1 + (total / 2) * c2);
2828
}
2929

3030
return (int) (res % mod);

0 commit comments

Comments
 (0)