結果
| 問題 | No.564 背の順 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-01-24 21:19:17 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 165 ms / 2,000 ms | 
| コード長 | 829 bytes | 
| コンパイル時間 | 3,829 ms | 
| コンパイル使用メモリ | 85,232 KB | 
| 実行使用メモリ | 41,740 KB | 
| 最終ジャッジ日時 | 2024-12-26 07:56:38 | 
| 合計ジャッジ時間 | 6,430 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 | 
ソースコード
package me.yukicoder.lv1;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class No0564 {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int h = sc.nextInt();
			int num = sc.nextInt();
			int cnt = 1;
			List<Integer> l = new ArrayList<>();
			l.add(h);
			for (int i = 1; i < num; i++) {
				l.add(sc.nextInt());
			}
			Collections.sort(l);
			Collections.reverse(l);
			for (int i : l) {
				if (i == h)
					break;
				cnt++;
			}
			// 一の位の判断
			if (cnt % 10 == 1) {
				System.out.println(cnt + "st");
			} else if (cnt % 10 == 2) {
				System.out.println(cnt + "nd");
			} else if (cnt % 10 == 3) {
				System.out.println(cnt + "rd");
			} else {
				System.out.println(cnt + "th");
			}
		}
	}
}
            
            
            
        