結果

問題 No.564 背の順
ユーザー tsunabittsunabit
提出日時 2018-07-08 18:48:43
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 741 bytes
コンパイル時間 3,873 ms
コンパイル使用メモリ 82,308 KB
実行使用メモリ 57,876 KB
最終ジャッジ日時 2023-09-22 07:50:31
合計ジャッジ時間 6,618 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
55,404 KB
testcase_01 AC 149 ms
56,092 KB
testcase_02 AC 156 ms
56,152 KB
testcase_03 AC 150 ms
55,720 KB
testcase_04 AC 147 ms
55,556 KB
testcase_05 AC 159 ms
55,740 KB
testcase_06 AC 158 ms
56,168 KB
testcase_07 AC 152 ms
55,660 KB
testcase_08 WA -
testcase_09 AC 148 ms
55,396 KB
testcase_10 AC 146 ms
55,744 KB
testcase_11 AC 146 ms
57,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.stream.Stream;
import java.time.*;
import java.time.format.*;

public class No564 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		Integer[] hh = new Integer[n];
		for(int i = 0; i < n - 1; i++) {
			hh[i] = sc.nextInt();
		}
		hh[n - 1] = h;
		Arrays.sort(hh, Collections.reverseOrder());

		for(int i = 0; i < n; i++) {
			if(h == hh[i]) {
				if(i == 0) {
					System.out.println(i + 1 + "st");
				}else if(i%10 == 1) {
					System.out.println(i + 1 + "nd");
				}else if(i%10 == 2) {
					System.out.println(i + 1 + "rd");
				}else {
					System.out.println(i + 1 + "th");
				}
				return;
			}
		}

	}
}
0