結果

問題 No.564 背の順
コンテスト
ユーザー Tsukasa_Type
提出日時 2018-02-09 03:03:30
言語 Java
(openjdk 27 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
WA  
実行時間 -
コード長 663 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,645 ms
コンパイル使用メモリ 91,068 KB
実行使用メモリ 45,732 KB
最終ジャッジ日時 2026-09-08 14:02:39
合計ジャッジ時間 3,775 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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