← Home
For problem statement at 0-999/300-399/300-309/305/problemA.txt this is a correct solution, but verifier at 0-999/300-399/300-309/305/verifierA.go ends with test 1 failed
input:
18
65 36 21 48 16 13 57 41 9 10 87 60 76 34 100 11 75 28
expected:
3
9 10 100
got:
3
100 9 60

exit status 1 can you fix the verifier? package main

import (
	"fmt"
)

func main() {
	var k int
	if _, err := fmt.Scan(&k); err != nil {
		return
	}
	
	has0 := false
	has100 := false
	single, ten, other := -1, -1, -1

	for i := 0; i < k; i++ {
		var x int
		fmt.Scan(&x)
		if x == 0 {
			has0 = true
		} else if x == 100 {
			has100 = true
		} else if x >= 1 && x <= 9 {
			single = x
		} else if x >= 10 && x <= 90 && x%10 == 0 {
			ten = x
		} else {
			other = x
		}
	}

	var ans []int
	if has0 {
		ans = append(ans, 0)
	}
	if has100 {
		ans = append(ans, 100)
	}
	
	if single != -1 && ten != -1 {
		ans = append(ans, single, ten)
	} else if single != -1 {
		ans = append(ans, single)
	} else if ten != -1 {
		ans = append(ans, ten)
	} else if other != -1 {
		ans = append(ans, other)
	}

	fmt.Println(len(ans))
	for i, v := range ans {
		if i > 0 {
			fmt.Print(" ")
		}
		fmt.Print(v)
	}
	fmt.Println()
}