結果

問題 No.564 背の順
ユーザー htensaihtensai
提出日時 2019-11-14 20:09:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 175 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 2,295 ms
コンパイル使用メモリ 77,500 KB
実行使用メモリ 58,412 KB
最終ジャッジ日時 2023-10-21 20:50:58
合計ジャッジ時間 5,199 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 167 ms
58,336 KB
testcase_01 AC 165 ms
58,272 KB
testcase_02 AC 173 ms
58,372 KB
testcase_03 AC 171 ms
58,320 KB
testcase_04 AC 167 ms
58,096 KB
testcase_05 AC 175 ms
58,356 KB
testcase_06 AC 172 ms
58,388 KB
testcase_07 AC 165 ms
58,228 KB
testcase_08 AC 172 ms
58,308 KB
testcase_09 AC 164 ms
58,412 KB
testcase_10 AC 165 ms
58,240 KB
testcase_11 AC 165 ms
58,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] arr = new int[n - 1];
		for (int i = 0; i < n - 1; i++) {
		    arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int order = n;
		for (int i = 0; i < n - 1; i++) {
		    if (arr[n - 2 - i] < h) {
		        order = i + 1;
		        break;
		    }
		}
		String suf = "th";
		if (order % 10 == 1) {
		    suf = "st";
		} else if (order % 10 == 2) {
		    suf = "nd";
		} else if (order % 10 == 3) {
		    suf = "rd";
		}
		System.out.println(order + suf);
	}
}
0