結果
問題 | No.564 背の順 |
ユーザー | takeya_okino |
提出日時 | 2017-09-18 22:38:30 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 150 ms / 2,000 ms |
コード長 | 709 bytes |
コンパイル時間 | 2,275 ms |
コンパイル使用メモリ | 77,944 KB |
実行使用メモリ | 54,724 KB |
最終ジャッジ日時 | 2024-04-25 15:34:13 |
合計ジャッジ時間 | 4,394 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 146 ms
54,444 KB |
testcase_01 | AC | 142 ms
54,724 KB |
testcase_02 | AC | 148 ms
54,432 KB |
testcase_03 | AC | 143 ms
54,464 KB |
testcase_04 | AC | 140 ms
54,288 KB |
testcase_05 | AC | 149 ms
54,424 KB |
testcase_06 | AC | 150 ms
54,156 KB |
testcase_07 | AC | 140 ms
54,228 KB |
testcase_08 | AC | 142 ms
54,140 KB |
testcase_09 | AC | 130 ms
53,620 KB |
testcase_10 | AC | 138 ms
54,272 KB |
testcase_11 | AC | 137 ms
54,248 KB |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int n = sc.nextInt(); int[] height = new int[n - 1]; for(int i = 0; i < n - 1; i++) { height[i] = sc.nextInt(); } Arrays.sort(height); int ord = n; for(int i = n - 2; i >= 0; i--) { if(height[i] < h) { ord = n - i - 1; break; } } String ans = ""; if((ord % 10) == 1) { ans = ord + "st"; } else if((ord % 10) == 2) { ans = ord + "nd"; } else if((ord % 10) == 3) { ans = ord + "rd"; } else { ans = ord + "th"; } System.out.println(ans); } }