// No.564 背の順 package main import ( "fmt" "sort" "strconv" "strings" ) func main() { var h, n int // なま君身長、クラス人数 fmt.Scan(&h, &n) l := make([]int, n) l[0] = h for i := 1; i < n; i++ { fmt.Scan(&l[i]) } sort.Sort(sort.Reverse(sort.IntSlice(l))) rank := 0 for _, v := range l { rank++ if v == h { if strings.HasSuffix(strconv.Itoa(rank), "1") { fmt.Println(strconv.Itoa(rank) + "st") } else if strings.HasSuffix(strconv.Itoa(rank), "2") { fmt.Println(strconv.Itoa(rank) + "nd") } else if strings.HasSuffix(strconv.Itoa(rank), "3") { fmt.Println(strconv.Itoa(rank) + "rd") } else { fmt.Println(strconv.Itoa(rank) + "th") } break } } }