← Home
For problem statement at 0-999/200-299/260-269/260/problemC.txt this is a correct solution, but verifier at 0-999/200-299/260-269/260/verifierC.go ends with All tests passed can you fix the verifier? package main

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

func main() {
	in := bufio.NewReaderSize(os.Stdin, 1<<20)
	out := bufio.NewWriterSize(os.Stdout, 1<<20)
	defer out.Flush()

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

	a := make([]int64, n)
	minVal := int64(1<<63 - 1)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
		if a[i] < minVal {
			minVal = a[i]
		}
	}

	x--
	pos := x
	for a[pos] != minVal {
		pos--
		if pos < 0 {
			pos = n - 1
		}
	}

	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = a[i] - minVal
	}

	r := (x - pos + n) % n
	for t := 1; t <= r; t++ {
		idx := (pos + t) % n
		res[idx]--
	}

	res[pos] = minVal*int64(n) + int64(r)

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