結果
| 問題 | No.564 背の順 | 
| コンテスト | |
| ユーザー |  takeya_okino | 
| 提出日時 | 2017-09-18 22:38:30 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 163 ms / 2,000 ms | 
| コード長 | 709 bytes | 
| コンパイル時間 | 2,314 ms | 
| コンパイル使用メモリ | 76,656 KB | 
| 実行使用メモリ | 54,368 KB | 
| 最終ジャッジ日時 | 2024-11-08 02:38:05 | 
| 合計ジャッジ時間 | 4,949 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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[] height = new int[n - 1];
    for(int i = 0; i < n - 1; i++) {
      height[i] = sc.nextInt();
    }
    Arrays.sort(height);
    int ord = n;
    for(int i = n - 2; i >= 0; i--) {
      if(height[i] < h) {
        ord = n - i - 1;
        break;
      }
    }
    String ans = "";
    if((ord % 10) == 1) {
      ans = ord + "st";
    } else if((ord % 10) == 2) {
      ans = ord + "nd";
    } else if((ord % 10) == 3) {
      ans = ord + "rd";
    } else {
      ans = ord + "th";
    }
    System.out.println(ans);
  }
}
            
            
            
        