結果

問題 No.564 背の順
ユーザー rkyrky
提出日時 2017-11-26 19:39:00
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 398 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 12,416 ms
コンパイル使用メモリ 442,984 KB
実行使用メモリ 61,848 KB
最終ジャッジ日時 2024-04-30 16:28:14
合計ジャッジ時間 16,002 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 380 ms
61,828 KB
testcase_01 AC 380 ms
61,620 KB
testcase_02 AC 387 ms
61,736 KB
testcase_03 AC 394 ms
61,776 KB
testcase_04 AC 379 ms
61,620 KB
testcase_05 AC 386 ms
61,708 KB
testcase_06 AC 390 ms
61,776 KB
testcase_07 AC 398 ms
61,724 KB
testcase_08 AC 392 ms
61,848 KB
testcase_09 AC 382 ms
61,712 KB
testcase_10 AC 373 ms
61,776 KB
testcase_11 AC 375 ms
61,684 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 rank = list.indexOf(nama).toString().split("")
	var ele = rank[rank.size - 2]
	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