結果

問題 No.564 背の順
ユーザー cande398cande398
提出日時 2017-10-07 01:50:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 1,942 ms
コンパイル使用メモリ 75,000 KB
実行使用メモリ 54,344 KB
最終ジャッジ日時 2024-04-28 11:56:48
合計ジャッジ時間 3,945 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
53,980 KB
testcase_01 AC 118 ms
53,952 KB
testcase_02 AC 125 ms
53,996 KB
testcase_03 AC 118 ms
54,076 KB
testcase_04 AC 113 ms
54,108 KB
testcase_05 AC 125 ms
54,140 KB
testcase_06 AC 120 ms
53,604 KB
testcase_07 AC 107 ms
53,220 KB
testcase_08 AC 128 ms
54,344 KB
testcase_09 AC 103 ms
53,196 KB
testcase_10 AC 112 ms
54,092 KB
testcase_11 AC 107 ms
53,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int i, num = 0;
    int Nama = sc.nextInt();
    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((num-i)%10>0 && (num-i)%10<4){
          System.out.println(str[((num-i)%10)-1]);
        }
        else System.out.println(str[3]);
      }
    }
  }
}
0