結果

問題 No.564 背の順
ユーザー cande398cande398
提出日時 2017-10-07 01:21:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 601 bytes
コンパイル時間 1,998 ms
コンパイル使用メモリ 83,924 KB
実行使用メモリ 41,748 KB
最終ジャッジ日時 2024-04-28 11:55:00
合計ジャッジ時間 4,083 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,744 KB
testcase_01 AC 121 ms
41,416 KB
testcase_02 AC 134 ms
41,748 KB
testcase_03 WA -
testcase_04 AC 126 ms
41,172 KB
testcase_05 AC 129 ms
41,272 KB
testcase_06 AC 124 ms
41,260 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 118 ms
41,632 KB
testcase_10 AC 96 ms
39,860 KB
testcase_11 AC 108 ms
41,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int i;
    int Nama = sc.nextInt();
    int num = sc.nextInt();
    int[] height = new int[num];
    String[] str = {"st", "nd", "rd", "th"};
    height[0] = Nama;
    for(i=1;i<num;i++){
      height[i] = sc.nextInt();
    }
    Arrays.sort(height);

    for(i=0;i<num;i++){
      if(height[i] == Nama){
        System.out.print(num-i);
        if(i>num-4){
          System.out.println(str[num-i-1]);
        }
        else System.out.println(str[3]);
      }
    }
  }
}
0