結果

問題 No.564 背の順
ユーザー YOSHIYOSHI
提出日時 2021-03-20 11:15:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 930 bytes
コンパイル時間 4,174 ms
コンパイル使用メモリ 85,372 KB
実行使用メモリ 51,352 KB
最終ジャッジ日時 2024-04-30 22:06:11
合計ジャッジ時間 5,814 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
51,180 KB
testcase_01 AC 78 ms
51,096 KB
testcase_02 AC 79 ms
51,180 KB
testcase_03 AC 78 ms
51,220 KB
testcase_04 AC 78 ms
51,148 KB
testcase_05 AC 75 ms
50,888 KB
testcase_06 AC 78 ms
50,924 KB
testcase_07 AC 76 ms
50,828 KB
testcase_08 AC 77 ms
50,788 KB
testcase_09 AC 74 ms
50,792 KB
testcase_10 AC 75 ms
51,304 KB
testcase_11 AC 78 ms
51,352 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());
		for(int j = 0; j < n - 1; j++) {
			if(l[j] < h) {
				if(j % 10 == 0) System.out.println((j + 1) + "st");
				if(j % 10 == 1) System.out.println((j + 1) + "nd");
				if(j % 10 == 2) System.out.println((j + 1) + "rd");
				if(j % 10 > 2) System.out.println((j + 1) + "th");
				return;
			}
		}
		System.out.println(n + "th");
	}
}
0