結果

問題 No.564 背の順
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-09 03:14:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 716 bytes
コンパイル時間 2,144 ms
コンパイル使用メモリ 80,300 KB
実行使用メモリ 54,472 KB
最終ジャッジ日時 2024-04-10 06:02:52
合計ジャッジ時間 4,655 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
54,272 KB
testcase_01 AC 138 ms
54,232 KB
testcase_02 AC 148 ms
54,460 KB
testcase_03 AC 142 ms
54,108 KB
testcase_04 AC 126 ms
53,124 KB
testcase_05 AC 152 ms
54,396 KB
testcase_06 AC 149 ms
54,204 KB
testcase_07 AC 142 ms
54,244 KB
testcase_08 AC 149 ms
54,464 KB
testcase_09 AC 140 ms
54,424 KB
testcase_10 AC 139 ms
54,472 KB
testcase_11 AC 141 ms
54,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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