結果

問題 No.564 背の順
コンテスト
ユーザー jimano
提出日時 2018-01-27 14:41:25
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 745 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,689 ms
コンパイル使用メモリ 84,552 KB
実行使用メモリ 42,712 KB
最終ジャッジ日時 2026-06-03 02:38:37
合計ジャッジ時間 5,607 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.Arrays;
import java.util.Scanner;

public class No0564_2 {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int height = sc.nextInt();
			int num = sc.nextInt();
			int cnt = 1;
			int[] h = new int[num];
			h[0] = height;

			for (int i = 1; i < num; i++) {
				h[i] = sc.nextInt();
			}
			Arrays.sort(h);

			for (int i = h.length - 1; i > 0; i--) {
				if (h[i] == height)
					break;
				cnt++;
			}

			// 一の位の判断
			if (cnt % 10 == 1) {
				System.out.println(cnt + "st");
			} else if (cnt % 10 == 2) {
				System.out.println(cnt + "nd");
			} else if (cnt % 10 == 3) {
				System.out.println(cnt + "rd");
			} else {
				System.out.println(cnt + "th");
			}
		}
	}
}
0