結果

問題 No.564 背の順
ユーザー YOSHIYOSHI
提出日時 2021-03-20 11:22:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 923 bytes
コンパイル時間 3,999 ms
コンパイル使用メモリ 80,920 KB
実行使用メモリ 51,236 KB
最終ジャッジ日時 2024-04-30 22:10:24
合計ジャッジ時間 5,787 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
51,236 KB
testcase_01 AC 75 ms
51,200 KB
testcase_02 AC 79 ms
50,896 KB
testcase_03 AC 85 ms
51,092 KB
testcase_04 AC 84 ms
51,064 KB
testcase_05 AC 82 ms
51,200 KB
testcase_06 AC 82 ms
51,220 KB
testcase_07 AC 81 ms
51,176 KB
testcase_08 AC 76 ms
51,184 KB
testcase_09 AC 78 ms
50,748 KB
testcase_10 AC 77 ms
50,704 KB
testcase_11 AC 80 ms
50,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;

public class No00000564_Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args) throws IOException {
		String[] hn = br.readLine().split(" ");
		int h  = Integer.parseInt(hn[0]);
		int n = Integer.parseInt(hn[1]);
		Integer[] l = new Integer[n-1];
		for(int i = 0;i < n - 1; i++) {
			l[i] = Integer.parseInt(br.readLine());
		}
		Arrays.sort(l, Collections.reverseOrder());
		int r = n;
		for(int j = 0; j < n - 1; j++) {
			if(l[j] < h) {
				r = j + 1;
				break;
			}
		}
		if(r % 10 == 1) {
			System.out.println(r + "st");
		} else if(r % 10 == 2) {
			System.out.println(r + "nd");
		} else if(r % 10 == 3) {
			System.out.println(r + "rd");
		} else {
			System.out.println(r + "th");
		}
	}
}
0