結果
問題 |
No.564 背の順
|
ユーザー |
![]() |
提出日時 | 2018-02-09 03:11:03 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 706 bytes |
コンパイル時間 | 2,940 ms |
コンパイル使用メモリ | 81,236 KB |
実行使用メモリ | 54,696 KB |
最終ジャッジ日時 | 2024-10-02 06:45:16 |
合計ジャッジ時間 | 4,858 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 WA * 4 |
ソースコード
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int h = sc.nextInt(); int n = sc.nextInt(); Integer[] ints = new Integer[n-1]; for (int i=0; i<n-1; i++) { ints[i] = sc.nextInt(); } Arrays.sort(ints,Comparator.reverseOrder()); int rank = 0; for (int i=0; i<n-2; i++) { if (ints[i]>h && ints[i+1]<h) {rank = i+2;} } if (ints[0]<h) {rank = 1;} else if (ints[n-2]>h) {rank = n;} int temp = rank%10; if (temp==1) {System.out.println(rank+"st");} else if (temp==2) {System.out.println(rank+"nd");} else if (temp==3) {System.out.println(rank+"rd");} else {System.out.println(temp+"th");} } }