結果

問題 No.564 背の順
ユーザー jimanojimano
提出日時 2018-01-27 14:41:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 3,516 ms
コンパイル使用メモリ 76,092 KB
実行使用メモリ 57,968 KB
最終ジャッジ日時 2023-08-28 09:53:04
合計ジャッジ時間 6,293 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
55,940 KB
testcase_01 AC 135 ms
56,224 KB
testcase_02 AC 145 ms
54,080 KB
testcase_03 AC 137 ms
57,968 KB
testcase_04 AC 134 ms
56,204 KB
testcase_05 AC 144 ms
56,256 KB
testcase_06 AC 146 ms
55,904 KB
testcase_07 AC 136 ms
55,936 KB
testcase_08 AC 147 ms
55,916 KB
testcase_09 AC 136 ms
55,456 KB
testcase_10 AC 137 ms
55,992 KB
testcase_11 AC 138 ms
55,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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