結果
問題 |
No.564 背の順
|
ユーザー |
![]() |
提出日時 | 2018-06-04 14:52:44 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 171 ms / 2,000 ms |
コード長 | 643 bytes |
コンパイル時間 | 3,793 ms |
コンパイル使用メモリ | 78,284 KB |
実行使用メモリ | 42,772 KB |
最終ジャッジ日時 | 2024-06-30 09:37:19 |
合計ジャッジ時間 | 6,511 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
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); } }