結果

問題 No.564 背の順
ユーザー creep04creep04
提出日時 2017-10-11 03:27:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 3,741 ms
コンパイル使用メモリ 77,116 KB
実行使用メモリ 54,620 KB
最終ジャッジ日時 2024-04-28 15:41:49
合計ジャッジ時間 6,230 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
54,184 KB
testcase_01 AC 133 ms
54,040 KB
testcase_02 AC 158 ms
54,284 KB
testcase_03 WA -
testcase_04 AC 151 ms
54,340 KB
testcase_05 AC 160 ms
54,304 KB
testcase_06 AC 144 ms
54,268 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 133 ms
53,924 KB
testcase_10 AC 148 ms
54,336 KB
testcase_11 AC 133 ms
53,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Test4 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		List<Integer> ar = new ArrayList<Integer>();
		ar.add(0, h);
		for (int i=1; i<n; i++) {
			ar.add(i, sc.nextInt());
		}
		Collections.sort(ar);
		Collections.reverse(ar);
		int ans = ar.indexOf(h)+1;
		if (ans==1) {
			System.out.println("1st");
		} else if (ans==2) {
			System.out.println("2nd");
		} else if (ans==3) {
			System.out.println("3rd");
		} else {
			System.out.println(ans + "th");
		}
		
	}
}
0