結果

問題 No.564 背の順
ユーザー tentententen
提出日時 2020-12-09 14:25:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 837 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 75,396 KB
実行使用メモリ 41,508 KB
最終ジャッジ日時 2024-09-19 01:09:38
合計ジャッジ時間 4,724 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
41,340 KB
testcase_01 AC 135 ms
41,476 KB
testcase_02 AC 142 ms
41,332 KB
testcase_03 AC 124 ms
40,204 KB
testcase_04 AC 139 ms
41,300 KB
testcase_05 AC 147 ms
41,436 KB
testcase_06 AC 145 ms
41,432 KB
testcase_07 AC 137 ms
40,944 KB
testcase_08 AC 145 ms
41,508 KB
testcase_09 AC 138 ms
41,116 KB
testcase_10 AC 136 ms
40,812 KB
testcase_11 AC 135 ms
41,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] arr = new int[n];
        arr[0] = h;
        for (int i = 1; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (arr[n - i] == h) {
                ans = i;
                break;
            }
        }
        System.out.print(ans);
        if (ans % 10 == 1) {
            System.out.println("st");
        } else if (ans % 10 == 2) {
            System.out.println("nd");
        } else if (ans % 10 == 3) {
            System.out.println("rd");
        } else {
            System.out.println("th");
        }
    }
}
0