結果

問題 No.564 背の順
ユーザー jimanojimano
提出日時 2018-01-24 21:19:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 3,306 ms
コンパイル使用メモリ 75,204 KB
実行使用メモリ 56,340 KB
最終ジャッジ日時 2023-08-27 02:18:04
合計ジャッジ時間 5,793 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
55,556 KB
testcase_01 AC 134 ms
56,052 KB
testcase_02 AC 142 ms
55,956 KB
testcase_03 AC 140 ms
56,188 KB
testcase_04 AC 137 ms
55,752 KB
testcase_05 AC 148 ms
56,064 KB
testcase_06 AC 147 ms
55,788 KB
testcase_07 AC 139 ms
55,888 KB
testcase_08 AC 151 ms
56,340 KB
testcase_09 AC 136 ms
55,708 KB
testcase_10 AC 139 ms
55,932 KB
testcase_11 AC 140 ms
55,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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");
			}
		}
	}
}
0