結果
| 問題 | No.564 背の順 | 
| コンテスト | |
| ユーザー |  tenten | 
| 提出日時 | 2020-12-09 14:25:10 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                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 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 | 
ソースコード
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");
        }
    }
}
            
            
            
        