結果

問題 No.564 背の順
ユーザー jimanojimano
提出日時 2018-01-24 21:19:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 3,426 ms
コンパイル使用メモリ 80,836 KB
実行使用メモリ 54,632 KB
最終ジャッジ日時 2024-06-07 21:58:25
合計ジャッジ時間 5,920 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
54,432 KB
testcase_01 AC 140 ms
54,100 KB
testcase_02 AC 148 ms
54,348 KB
testcase_03 AC 140 ms
54,172 KB
testcase_04 AC 140 ms
54,120 KB
testcase_05 AC 158 ms
54,404 KB
testcase_06 AC 152 ms
54,532 KB
testcase_07 AC 149 ms
54,632 KB
testcase_08 AC 152 ms
54,384 KB
testcase_09 AC 145 ms
54,276 KB
testcase_10 AC 145 ms
54,288 KB
testcase_11 AC 144 ms
54,220 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