結果

問題 No.564 背の順
ユーザー ゆうPゆうP
提出日時 2024-03-30 02:20:27
言語 Go
(1.22.1)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 10,561 ms
コンパイル使用メモリ 209,652 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-30 02:20:39
合計ジャッジ時間 11,222 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 1 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 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
		}
	}
}
0