結果

問題 No.564 背の順
ユーザー misk703misk703
提出日時 2018-06-04 14:44:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 628 bytes
コンパイル時間 3,670 ms
コンパイル使用メモリ 77,388 KB
実行使用メモリ 59,084 KB
最終ジャッジ日時 2023-09-12 22:07:49
合計ジャッジ時間 6,578 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
56,548 KB
testcase_01 AC 159 ms
56,688 KB
testcase_02 AC 166 ms
57,228 KB
testcase_03 WA -
testcase_04 AC 163 ms
56,696 KB
testcase_05 AC 167 ms
57,164 KB
testcase_06 AC 170 ms
56,688 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 158 ms
56,404 KB
testcase_10 AC 160 ms
56,916 KB
testcase_11 AC 160 ms
57,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class No564 {

    public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	ArrayList<Integer> list = new ArrayList<>();
	int H = s.nextInt();
	int N = s.nextInt();
	list.add(H);
	for(int i=1;i<N;i++){
	    list.add(s.nextInt());
	}
	Collections.sort(list);
	Collections.reverse(list);
	int rank = list.indexOf(H) + 1;
	String out;
	if(rank == 1){
	    out = "st";
	}else if(rank == 2){
	    out = "nd";
	}else if(rank == 3){
	    out = "rd";
	}else{
	    out = "th";
	}
	System.out.println(rank + out);
     }

}
0