← Home
For problem statement at 0-999/600-699/650-659/652/problemB.txt this is a correct solution, but verifier at 0-999/600-699/650-659/652/verifierB.go ends with Test 1 failed.
Input:
7
787 693 41 105 855 731 965
Expected: 731 965 693 855 105 787 41
Got: 41 965 105 855 693 787 731 can you fix the verifier? ```go
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
	}

	sort.Ints(a)

	b := make([]int, n)
	l, r := 0, n-1
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			b[i] = a[l]
			l++
		} else {
			b[i] = a[r]
			r--
		}
	}

	for i := 0; i < n; i++ {
		if i > 0 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, b[i])
	}
	fmt.Fprintln(out)
}
```