結果
| 問題 | No.564 背の順 | 
| コンテスト | |
| ユーザー |  R_F | 
| 提出日時 | 2017-11-22 14:25:48 | 
| 言語 | Go (1.23.4) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 851 bytes | 
| コンパイル時間 | 10,332 ms | 
| コンパイル使用メモリ | 231,292 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-26 11:13:25 | 
| 合計ジャッジ時間 | 10,899 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 | 
ソースコード
package main
import (
	"fmt"
	"sort"
	"strconv"
	"strings"
)
func heightNum(num int, heights *[]int) {
	for i := 1; i < num; i++ {
		var val int
		fmt.Scan(&val)
		*heights = append(*heights, val)
	}
}
func appendSort(height int, heightSlice *[]int) {
	*heightSlice = append(*heightSlice, height)
	sort.Ints(*heightSlice)
}
func ranking(i int) {
	l := strings.Split(strconv.Itoa(i), "")
	if l[len(l)-1] == "1" {
		fmt.Printf("%dst\n", i)
	} else if l[len(l)-1] == "2" {
		fmt.Printf("%dnd\n", i)
	} else if l[len(l)-1] == "3" {
		fmt.Printf("%drd\n", i)
	} else {
		fmt.Printf("%dth\n", i)
	}
}
func main() {
	var height, num int
	fmt.Scan(&height, &num)
	heightSlice := []int{}
	heightNum(num, &heightSlice)
	appendSort(height, &heightSlice)
	for i, v := range heightSlice {
		if v == height {
			ranking(len(heightSlice) - i)
			break
		}
	}
}
            
            
            
        