結果
問題 |
No.564 背の順
|
ユーザー |
![]() |
提出日時 | 2018-06-04 14:44:37 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 628 bytes |
コンパイル時間 | 3,612 ms |
コンパイル使用メモリ | 78,596 KB |
実行使用メモリ | 55,200 KB |
最終ジャッジ日時 | 2024-06-30 09:36:41 |
合計ジャッジ時間 | 6,311 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 3 |
ソースコード
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 == 1){ out = "st"; }else if(rank == 2){ out = "nd"; }else if(rank == 3){ out = "rd"; }else{ out = "th"; } System.out.println(rank + out); } }