結果

問題 No.564 背の順
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-09-30 14:56:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 1,202 bytes
コンパイル時間 3,109 ms
コンパイル使用メモリ 83,676 KB
実行使用メモリ 51,364 KB
最終ジャッジ日時 2024-04-27 16:54:15
合計ジャッジ時間 4,471 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
51,064 KB
testcase_01 AC 62 ms
50,988 KB
testcase_02 AC 72 ms
50,984 KB
testcase_03 AC 63 ms
51,080 KB
testcase_04 AC 66 ms
50,988 KB
testcase_05 AC 65 ms
50,628 KB
testcase_06 AC 75 ms
50,928 KB
testcase_07 AC 73 ms
51,176 KB
testcase_08 AC 65 ms
50,984 KB
testcase_09 AC 63 ms
51,364 KB
testcase_10 AC 64 ms
50,928 KB
testcase_11 AC 61 ms
50,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class No564 {

	public static void main(String[] args){
	    try{
		    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		    String[] temp = br.readLine().split(" ");
		    int H = Integer.parseInt(temp[0]);
		    int N = Integer.parseInt(temp[1]);
		    int[] heights = new int[N];
		    for(int i=1; i < N; i++)
		    	heights[i] = Integer.parseInt(br.readLine());
		    heights[0] = H;
		    Arrays.sort(heights);
		    
		    int count = 0;
		    for(int i=0; i < N; i++){
		    	if(heights[i] == H){ 
		    		count = i+1;
		    		break;
		    	}
		    }
		    
		    int hitoketa = (N - count + 1) % 10;
		    switch(hitoketa){
		        case 1:
		        	System.out.println((N - count + 1) + "st");
		        	break;
		        case 2:
		        	System.out.println((N - count + 1) + "nd");
		        	break;
		        case 3:
		        	System.out.println((N - count + 1) + "rd");
		        	break;
		        default:
		        	System.out.println((N - count + 1) + "th");
		        	break;
		   }
	       }catch(Exception e){
	    	   e.getStackTrace();
	       }
	}
}
0