結果

問題 No.564 背の順
ユーザー mijimemijime
提出日時 2018-03-06 21:36:22
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 916 bytes
コンパイル時間 13,630 ms
コンパイル使用メモリ 218,688 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 19:10:59
合計ジャッジ時間 13,295 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"

	"strconv"
	"strings"
)

func Run(in io.Reader, out io.Writer) error {
	sc := bufio.NewScanner(in)
	sc.Scan()
	lineText := sc.Text()
	lines := strings.Split(lineText, " ")
	targetHeightText := lines[0]

	targetHeight, err := strconv.ParseInt(targetHeightText, 0, 64)

	if err != nil {
		return err
	}

	order := 1
	for sc.Scan() {
		heightText := sc.Text()
		height, parseErr := strconv.ParseInt(heightText, 0, 64)

		if parseErr != nil {
			return parseErr
		}

		if height > targetHeight {
			order++
		}
	}

	if (order % 10) == 1 {
		fmt.Fprintf(out, "%dst\n", order)
	} else if (order % 10) == 2 {
		fmt.Fprintf(out, "%dnd\n", order)
	} else if (order % 10) == 3 {
		fmt.Fprintf(out, "%drd\n", order)
	} else {
		fmt.Fprintf(out, "%dth\n", order)
	}

	return nil
}

func main() {
	err := Run(os.Stdin, os.Stdout)

	if err != nil {
		log.Fatal(err)
	}
}
0