For problem statement at 0-999/200-299/260-269/262/problemB.txt this is a correct solution, but verifier at 0-999/200-299/260-269/262/verifierB.go ends with All 100 tests passed can you fix the verifier? Looking at this problem, I need to maximize the sum after exactly k sign flips.
**Strategy:**
1. First, flip negative numbers (starting from the most negative ones, which are first in the sorted sequence) - this increases the sum
2. After flipping all negatives (or running out of them), if remaining k is:
- Even: can pair up flips on any number (no net effect)
- Odd: must flip the number with smallest absolute value (to minimize loss)
**Key insight:** Since the sequence is sorted non-decreasing, negative numbers come first. After flipping negatives, if k is odd, I need to flip the element with the smallest absolute value.
Let me trace through the examples:
- Example 1: `[-1, -1, 1]`, k=2 → flip both -1s → `[1, 1, 1]` → sum=3 ✓
- Example 2: `[1, 1, 1]`, k=1 → no negatives, k is odd → flip smallest (1) → `[-1, 1, 1]` → sum=1 ✓
```go
package main
import "fmt"
func abs(x int) int {
if x < 0 {
return -x
}
return x
}
func main() {
var n, k int
fmt.Scan(&n, &k)
a := make([]int, n)
for i := 0; i < n; i++ {
fmt.Scan(&a[i])
}
for i := 0; i < n && k > 0 && a[i] < 0; i++ {
a[i] = -a[i]
k--
}
sum := 0
minAbs := 10001
for i := 0; i < n; i++ {
sum += a[i]
if abs(a[i]) < minAbs {
minAbs = abs(a[i])
}
}
if k%2 == 1 {
sum -= 2 * minAbs
}
fmt.Println(sum)
}
```