結果

問題 No.564 背の順
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-09 03:03:30
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 2,282 ms
コンパイル使用メモリ 77,948 KB
実行使用メモリ 54,616 KB
最終ジャッジ日時 2024-04-10 02:24:38
合計ジャッジ時間 4,411 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,252 KB
testcase_01 AC 114 ms
53,564 KB
testcase_02 AC 140 ms
54,264 KB
testcase_03 WA -
testcase_04 AC 135 ms
54,156 KB
testcase_05 AC 140 ms
54,260 KB
testcase_06 AC 130 ms
54,220 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 106 ms
53,076 KB
testcase_10 AC 139 ms
54,264 KB
testcase_11 AC 123 ms
54,112 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;}
		}
		if (ints[0]<h) {System.out.println("1st");}
		else if (ints[n-2]>h) {System.out.println(n+"th");}
		else if (rank==2) {System.out.println("2nd");}
		else if (rank==3) {System.out.println("3rd");}
		else {System.out.println(rank+"th");}
	}
}
0