結果
| 問題 | No.564 背の順 | 
| コンテスト | |
| ユーザー |  creep04 | 
| 提出日時 | 2017-10-11 03:31:01 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 159 ms / 2,000 ms | 
| コード長 | 607 bytes | 
| コンパイル時間 | 4,025 ms | 
| コンパイル使用メモリ | 78,220 KB | 
| 実行使用メモリ | 41,840 KB | 
| 最終ジャッジ日時 | 2024-11-17 09:07:14 | 
| 合計ジャッジ時間 | 6,578 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 | 
ソースコード
import java.util.*;
public class Test4 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		List<Integer> ar = new ArrayList<Integer>();
		ar.add(0, h);
		for (int i=1; i<n; i++) {
			ar.add(i, sc.nextInt());
		}
		Collections.sort(ar);
		Collections.reverse(ar);
		int ans = ar.indexOf(h)+1;
		if (ans%10==1) {
			System.out.println(ans + "st");
		} else if (ans%10==2) {
			System.out.println(ans + "nd");
		} else if (ans%10==3) {
			System.out.println(ans + "rd");
		} else {
			System.out.println(ans + "th");
		}
		
	}
}
            
            
            
        