結果
| 問題 |
No.564 背の順
|
| コンテスト | |
| ユーザー |
atuk721
|
| 提出日時 | 2017-11-02 05:40:19 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 888 bytes |
| コンパイル時間 | 12,779 ms |
| コンパイル使用メモリ | 377,120 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-22 11:39:37 |
| 合計ジャッジ時間 | 14,359 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 3 |
ソースコード
use std::io;
fn main() {
let stdin = io::stdin();
let mut buf = String::with_capacity(256);
let mut vec: Vec<usize> = Vec::new();
stdin.read_line(&mut buf).unwrap();
let target: usize = buf.split_whitespace().next().unwrap().parse().unwrap();
buf.clear();
while let Ok(b) = stdin.read_line(&mut buf) {
if b == 0 {
break;
}
let height: usize = buf.trim().parse().unwrap();
vec.push(height);
buf.clear();
}
vec.sort_by(|a, b| b.cmp(a));
let order_check = vec.iter()
.zip(2..)
.take_while(|data| &target < data.0)
.last();
let order = match order_check {
Some(data) => data.1,
None => 1
};
let postfix = match order {
1 => "st",
2 => "nd",
3 => "rd",
_ => "th"
};
println!("{}{}", order, postfix);
}
atuk721