結果
問題 |
No.564 背の順
|
ユーザー |
![]() |
提出日時 | 2017-09-29 12:04:42 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 150 ms / 2,000 ms |
コード長 | 722 bytes |
コンパイル時間 | 2,678 ms |
コンパイル使用メモリ | 85,668 KB |
実行使用メモリ | 54,220 KB |
最終ジャッジ日時 | 2024-11-15 19:49:26 |
合計ジャッジ時間 | 5,229 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
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); } }