結果

問題 No.564 背の順
ユーザー creep04creep04
提出日時 2017-10-11 03:31:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 607 bytes
コンパイル時間 3,859 ms
コンパイル使用メモリ 78,084 KB
実行使用メモリ 54,576 KB
最終ジャッジ日時 2024-04-28 15:41:56
合計ジャッジ時間 6,412 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
53,736 KB
testcase_01 AC 149 ms
54,440 KB
testcase_02 AC 159 ms
54,324 KB
testcase_03 AC 151 ms
54,352 KB
testcase_04 AC 151 ms
54,168 KB
testcase_05 AC 157 ms
54,268 KB
testcase_06 AC 159 ms
54,432 KB
testcase_07 AC 152 ms
54,088 KB
testcase_08 AC 160 ms
54,536 KB
testcase_09 AC 149 ms
54,576 KB
testcase_10 AC 148 ms
54,084 KB
testcase_11 AC 150 ms
54,140 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%10==1) {
			System.out.println(ans + "st");
		} else if (ans%10==2) {
			System.out.println(ans + "nd");
		} else if (ans%10==3) {
			System.out.println(ans + "rd");
		} else {
			System.out.println(ans + "th");
		}
		
	}
}
0