結果

問題 No.564 背の順
ユーザー htensai
提出日時 2019-11-14 20:09:17
言語 Java
(openjdk 23)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 2,725 ms
コンパイル使用メモリ 77,188 KB
実行使用メモリ 42,648 KB
最終ジャッジ日時 2024-09-21 22:17:50
合計ジャッジ時間 5,137 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

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