結果

問題 No.564 背の順
ユーザー mijimemijime
提出日時 2018-03-06 21:29:34
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 868 bytes
コンパイル時間 12,804 ms
コンパイル使用メモリ 216,212 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 18:54:42
合計ジャッジ時間 13,553 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 WA -
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 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 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 == 1 {
		fmt.Fprint(out, "1st\n")
	} else if order == 2 {
		fmt.Fprint(out, "2nd\n")
	} else if order == 3 {
		fmt.Fprint(out, "3rd\n")
	} else {
		fmt.Fprintf(out, "%dth\n", order)
	}

	return nil
}

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

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