結果

問題 No.564 背の順
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2018-04-14 16:31:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 1,057 bytes
コンパイル時間 2,540 ms
コンパイル使用メモリ 77,000 KB
実行使用メモリ 56,424 KB
最終ジャッジ日時 2023-09-09 05:15:37
合計ジャッジ時間 4,712 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,908 KB
testcase_01 AC 122 ms
55,756 KB
testcase_02 AC 131 ms
56,240 KB
testcase_03 AC 127 ms
55,872 KB
testcase_04 AC 125 ms
55,388 KB
testcase_05 AC 136 ms
56,036 KB
testcase_06 AC 133 ms
56,200 KB
testcase_07 AC 124 ms
55,624 KB
testcase_08 AC 132 ms
55,784 KB
testcase_09 AC 121 ms
55,948 KB
testcase_10 AC 122 ms
55,860 KB
testcase_11 AC 123 ms
56,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        List<Integer> list = new ArrayList<>();
        int h0 = sc.nextInt();
        list.add(h0);
        
        int n = sc.nextInt();
        for(int i = 0; i < n-1; i++) {
            int tmp = sc.nextInt();
            list.add(tmp);
        }
        
        Collections.sort(list);
        Collections.reverse(list);
        
        for(int i = 0; i < n; i++) {
            if(h0 == list.get(i)) {
                display(i+1);
                break;
            }
        }
    }
    
    static void display(int index) {
        StringBuilder sb = new StringBuilder();
        sb.append(index);
        int redi = index%10;
        if(redi == 1) {
            sb.append("st");
        } else if(redi == 2) {
            sb.append("nd");
        } else if(redi == 3) {
            sb.append("rd");
        } else {
            sb.append("th");
        }
        System.out.println(sb.toString());
    }
}
0