結果
問題 | No.564 背の順 |
ユーザー | misk703 |
提出日時 | 2018-06-04 14:52:44 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 166 ms / 2,000 ms |
コード長 | 643 bytes |
コンパイル時間 | 5,477 ms |
コンパイル使用メモリ | 83,272 KB |
実行使用メモリ | 57,112 KB |
最終ジャッジ日時 | 2023-09-12 22:08:41 |
合計ジャッジ時間 | 8,248 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 158 ms
56,660 KB |
testcase_01 | AC | 156 ms
56,592 KB |
testcase_02 | AC | 162 ms
56,504 KB |
testcase_03 | AC | 160 ms
56,696 KB |
testcase_04 | AC | 156 ms
56,756 KB |
testcase_05 | AC | 165 ms
57,000 KB |
testcase_06 | AC | 166 ms
56,544 KB |
testcase_07 | AC | 159 ms
57,112 KB |
testcase_08 | AC | 166 ms
57,088 KB |
testcase_09 | AC | 156 ms
56,376 KB |
testcase_10 | AC | 156 ms
56,728 KB |
testcase_11 | AC | 159 ms
56,712 KB |
ソースコード
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class No564 { public static void main(String[] args) { Scanner s = new Scanner(System.in); ArrayList<Integer> list = new ArrayList<>(); int H = s.nextInt(); int N = s.nextInt(); list.add(H); for(int i=1;i<N;i++){ list.add(s.nextInt()); } Collections.sort(list); Collections.reverse(list); int rank = list.indexOf(H) + 1; String out; if(rank % 10 == 1){ out = "st"; }else if(rank % 10 == 2){ out = "nd"; }else if(rank % 10 == 3){ out = "rd"; }else{ out = "th"; } System.out.println(rank + out); } }