結果

問題 No.564 背の順
ユーザー FVRChanFVRChan
提出日時 2017-09-29 12:04:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 2,548 ms
コンパイル使用メモリ 78,312 KB
実行使用メモリ 54,232 KB
最終ジャッジ日時 2024-04-27 16:15:16
合計ジャッジ時間 5,192 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
53,804 KB
testcase_01 AC 117 ms
54,028 KB
testcase_02 AC 133 ms
54,232 KB
testcase_03 AC 108 ms
52,832 KB
testcase_04 AC 105 ms
52,980 KB
testcase_05 AC 128 ms
53,928 KB
testcase_06 AC 131 ms
54,064 KB
testcase_07 AC 129 ms
53,860 KB
testcase_08 AC 131 ms
54,216 KB
testcase_09 AC 110 ms
52,796 KB
testcase_10 AC 117 ms
54,028 KB
testcase_11 AC 121 ms
53,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Comparator;
import java.util.LinkedList;
import java.util.Scanner;
public class Main{
	private static Scanner sc=new Scanner(System.in);
	public static void main(String args[])throws Exception{
		int height=sc.nextInt(),n=sc.nextInt();
		LinkedList<Integer>queue=new LinkedList<Integer>();
		queue.offer(height);
		for(int i=0;i<n-1;i++)queue.offer(sc.nextInt());
		queue.sort(Comparator.reverseOrder());
		int counter=0;
		for(int i=0;i<queue.size();i++){
			if(queue.get(i)==height){
				counter=i+1;
				break;
			}
		}String s=String.valueOf(counter);
		switch(counter%10){
		case 1:s+="st";break;
		case 2:s+="nd";break;
		case 3:s+="rd";break;
		default:s+="th";break;
		}System.out.println(s);
	}
}
0