結果
問題 |
No.564 背の順
|
ユーザー |
![]() |
提出日時 | 2017-10-11 21:24:19 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 158 ms / 2,000 ms |
コード長 | 713 bytes |
コンパイル時間 | 4,519 ms |
コンパイル使用メモリ | 76,808 KB |
実行使用メモリ | 41,720 KB |
最終ジャッジ日時 | 2024-11-17 09:45:59 |
合計ジャッジ時間 | 5,374 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int n = sc.nextInt(); int[] x = new int[n]; x[0] = h; for(int i = 1 ; i < n ; i++) x[i] = sc.nextInt(); Arrays.sort(x); for(int i = n - 1 ; i >= 0 ; i--) { if(h == x[i]) { int rank = n - i; if(rank % 10 == 1) { System.out.println(rank + "st"); return; } else if(rank % 10 == 2) { System.out.println(rank + "nd"); return; } else if(rank % 10 == 3) { System.out.println(rank + "rd"); return; } else { System.out.println(rank + "th"); return; } } } } }