結果

問題 No.564 背の順
ユーザー k.hk.h
提出日時 2019-08-05 23:01:04
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 616 bytes
コンパイル時間 11,090 ms
コンパイル使用メモリ 203,000 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 17:35:20
合計ジャッジ時間 12,028 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	h, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	a := make([]int, n)
	a[0] = h
	for i := 1; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	num := 0
	for i := range a {
		if h == a[i] {
			num = i + 1
			break
		}
	}
	fmt.Print(num)
	switch num % 10 {
	case 1:
		fmt.Println("st")
	case 2:
		fmt.Println("nd")
	case 3:
		fmt.Println("rd")
	default:
		fmt.Println("th")
	}
}
0