結果

問題 No.564 背の順
ユーザー rkyrky
提出日時 2017-11-26 19:26:40
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 761 bytes
コンパイル時間 12,151 ms
コンパイル使用メモリ 442,568 KB
実行使用メモリ 61,976 KB
最終ジャッジ日時 2024-04-30 16:27:43
合計ジャッジ時間 15,086 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 376 ms
61,808 KB
testcase_01 WA -
testcase_02 AC 393 ms
61,736 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 369 ms
61,812 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 337 ms
61,668 KB
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:22:10: warning: parameter 'args' is never used
fun main(args: Array<String>){
         ^

ソースコード

diff #

import java.util.Scanner

var input = Scanner(System. `in`)

fun heightList(nama: Int, testCase: Int): MutableList<Int>{
	var list: MutableList<Int> = mutableListOf(nama)
	for(i in 1..testCase - 1) list.add( input.nextInt() )
	return list
}

fun result(list: MutableList<Int>, nama: Int){
	list.sortBy{ it * -1}
	var listIndex = list.indexOf(nama) + 1
	var ele =  (list.indexOf(nama).toString().split("")).size - 1
	
	if(ele == 0) println("${listIndex}st")
	else if(ele == 1) println("${listIndex}nd")
	else if(ele == 2) println("${listIndex}rd")
	else println("${listIndex}th")
}

fun main(args: Array<String>){
	var nama: Int = input.nextInt()
	var testCase: Int = input.nextInt()
	var list: MutableList<Int> = heightList(nama, testCase)
	result(list, nama)
}
0