結果
問題 |
No.564 背の順
|
ユーザー |
![]() |
提出日時 | 2017-10-11 03:27:21 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 583 bytes |
コンパイル時間 | 3,999 ms |
コンパイル使用メモリ | 77,632 KB |
実行使用メモリ | 54,384 KB |
最終ジャッジ日時 | 2024-11-17 09:07:08 |
合計ジャッジ時間 | 6,555 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 3 |
ソースコード
import java.util.*; public class Test4 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int n = sc.nextInt(); List<Integer> ar = new ArrayList<Integer>(); ar.add(0, h); for (int i=1; i<n; i++) { ar.add(i, sc.nextInt()); } Collections.sort(ar); Collections.reverse(ar); int ans = ar.indexOf(h)+1; if (ans==1) { System.out.println("1st"); } else if (ans==2) { System.out.println("2nd"); } else if (ans==3) { System.out.println("3rd"); } else { System.out.println(ans + "th"); } } }