結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
54,264 KB
testcase_01 AC 115 ms
53,996 KB
testcase_02 AC 143 ms
54,196 KB
testcase_03 WA -
testcase_04 AC 135 ms
54,128 KB
testcase_05 AC 143 ms
54,120 KB
testcase_06 AC 119 ms
53,632 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 123 ms
53,996 KB
testcase_10 AC 123 ms
52,884 KB
testcase_11 AC 111 ms
53,004 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