結果

問題 No.564 背の順
ユーザー tsunabittsunabit
提出日時 2018-07-08 18:53:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 4,572 ms
コンパイル使用メモリ 83,336 KB
実行使用メモリ 56,008 KB
最終ジャッジ日時 2023-09-22 08:08:43
合計ジャッジ時間 7,246 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
55,816 KB
testcase_01 AC 142 ms
55,528 KB
testcase_02 AC 148 ms
56,000 KB
testcase_03 AC 139 ms
55,940 KB
testcase_04 AC 138 ms
55,692 KB
testcase_05 AC 150 ms
56,008 KB
testcase_06 AC 154 ms
55,808 KB
testcase_07 AC 144 ms
55,936 KB
testcase_08 AC 149 ms
56,000 KB
testcase_09 AC 135 ms
55,844 KB
testcase_10 AC 136 ms
55,832 KB
testcase_11 AC 139 ms
55,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.stream.Stream;
import java.time.*;
import java.time.format.*;

public class No564 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		Integer[] hh = new Integer[n];
		hh[0] = h;
		for(int i = 1; i < n; i++) {
			hh[i] = sc.nextInt();
		}
		Arrays.sort(hh, Collections.reverseOrder());

		for(int i = 0; i < n; i++) {
			if(h == hh[i]) {
				int j = i + 1;
				if(j%10 == 1) {
					System.out.println(j + "st");
				}else if(j%10 == 2) {
					System.out.println(j + "nd");
				}else if(j%10 == 3) {
					System.out.println(j + "rd");
				}else {
					System.out.println(j + "th");
				}
				return;
			}
		}

	}
}
0