結果
| 問題 |
No.564 背の順
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-30 14:56:06 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 75 ms / 2,000 ms |
| コード長 | 1,202 bytes |
| コンパイル時間 | 3,858 ms |
| コンパイル使用メモリ | 85,872 KB |
| 実行使用メモリ | 38,480 KB |
| 最終ジャッジ日時 | 2024-11-15 20:47:15 |
| 合計ジャッジ時間 | 5,403 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
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();
}
}
}