結果

問題 No.564 背の順
ユーザー R_F
提出日時 2017-11-22 14:23:48
言語 Go
(1.23.4)
結果
WA  
実行時間 -
コード長 852 bytes
コンパイル時間 10,551 ms
コンパイル使用メモリ 220,132 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-26 11:12:53
合計ジャッジ時間 11,460 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

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.Println("%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
		}
	}
}
0