結果

問題 No.564 背の順
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-05-10 23:02:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 982 bytes
コンパイル時間 2,557 ms
コンパイル使用メモリ 74,328 KB
実行使用メモリ 56,912 KB
最終ジャッジ日時 2023-09-10 12:12:00
合計ジャッジ時間 4,808 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
56,684 KB
testcase_01 AC 137 ms
56,492 KB
testcase_02 AC 144 ms
55,844 KB
testcase_03 AC 138 ms
55,764 KB
testcase_04 AC 137 ms
55,824 KB
testcase_05 AC 147 ms
56,912 KB
testcase_06 AC 148 ms
56,284 KB
testcase_07 AC 141 ms
55,908 KB
testcase_08 AC 148 ms
56,164 KB
testcase_09 AC 136 ms
56,204 KB
testcase_10 AC 136 ms
55,844 KB
testcase_11 AC 139 ms
55,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int nama = in.nextInt();
        int n = in.nextInt();
        int[] h = new int[n-1];
        for(int i=0; i<n-1; i++)
            h[i] = in.nextInt();

        Arrays.sort(h);

        int pos = n;
        for(int i=n-2; i>=0; i--) {
            if(nama < h[i]) {
                continue;
            } else if(i == n-2 && nama > h[i]) {
                pos = 1;
                break;
            } else {
                pos = n - i - 1;
                break;
            }
        }

        switch(pos%10) {
        case 1:
            System.out.println(pos + "st");
            break;
        case 2:
            System.out.println(pos + "nd");
            break;
        case 3:
            System.out.println(pos + "rd");
            break;
        default:
            System.out.println(pos + "th");
            break;
        }
    }
}
0