No.564 Height Order
Problem Statement
Nama-kun, whose height is $H$[cm], became curious about where his height ranks in his class.
Nama-kun's class has $N$ students, including Nama-kun.
The heights of the other students are $H_i$[cm] ($1≦i≦N-1$).
Write a program that outputs the rank of Nama-kun's height.
Input
$H$ $N$
$H_1$
$H_2$
...
$H_{N-1}$
The input consists of $N$ lines.
The $1$st line contains Nama-kun's height $H$ ($1≦H≦1000$) and the number of students in the class $N$ ($2≦N≦100$), both integers, separated by a space.
The $i$-th of the following $N-1$ lines ($1≦i≦N-1$) contains an integer $H_i$ ($1≦H_i≦1000$), the height of a classmate other than Nama-kun.
$H$ and $H_i$ ($1≦i≦N-1$) are all distinct.
Output
Output the position of Nama-kun's height in the class, counted from the tallest, and
- if its ones digit is $1$, append st to the end.
- if its ones digit is $2$, append nd to the end.
- if its ones digit is $3$, append rd to the end.
- otherwise, append th to the end.
Print a newline at the end.
Sample
Sample 1
Input
157 4 178 164 155
Output
3rd
Nama-kun's height is $157$[cm] and the other students' heights are $178$[cm], $164$[cm], and $155$[cm], so Nama-kun is the $3$rd tallest.
Sample 2
Input
157 4 160 175 168
Output
4th
The other students' heights are not necessarily sorted already.
Sample 3
Input
188 10 146 178 160 165 182 174 2 166 186
Output
1st
Nama-kun is the tallest.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
makonagix
はむこ