結果

問題 No.564 背の順
コンテスト
ユーザー matsuyoshi30
提出日時 2018-05-10 23:06:19
言語 Java
(openjdk 27 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 156 ms / 2,000 ms
+ 624µs
コード長 1,284 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,042 ms
コンパイル使用メモリ 97,280 KB
実行使用メモリ 48,640 KB
最終ジャッジ日時 2026-10-15 18:31:11
合計ジャッジ時間 5,732 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int nama = in.nextInt();
        int n = in.nextInt();
        int[] h = new int[n-1];
        for(int i=0; i<n-1; i++)
            h[i] = in.nextInt();

        Arrays.sort(h);

        int pos = n;
        for(int i=n-2; i>=0; i--) {
            if(nama < h[i]) {
                continue;
            } else if(i == n-2 && nama > h[i]) {
                pos = 1;
                break;
            } else {
                pos = n - i - 1;
                break;
            }
        }

        /*
        switch(pos%10) {
        case 1:
            System.out.println(pos + "st");
            break;
        case 2:
            System.out.println(pos + "nd");
            break;
        case 3:
            System.out.println(pos + "rd");
            break;
        default:
            System.out.println(pos + "th");
            break;
        }
        */

          if(pos % 10 == 1)
          System.out.println(pos + "st");
          else if(pos % 10 == 2)
          System.out.println(pos + "nd");
          else if(pos % 10 == 3)
          System.out.println(pos + "rd");
          else
          System.out.println(pos + "th");

    }
}
0