結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 145 ms
54,632 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 155 ms
54,688 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 145 ms
54,336 KB
testcase_10 AC 130 ms
53,220 KB
testcase_11 AC 146 ms
54,208 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) {rank = 1;}
		else if (ints[n-2]>h) {rank = n;}
		rank %= 10;
		if (rank==1) {System.out.println(rank+"st");}
		else if (rank==2) {System.out.println(rank+"nd");}
		else if (rank==3) {System.out.println(rank+"rd");}
		else {System.out.println(rank+"th");}
	}
}
0