結果
| 問題 | No.564 背の順 | 
| コンテスト | |
| ユーザー |  atuk721 | 
| 提出日時 | 2017-11-02 05:43:59 | 
| 言語 | Rust (1.83.0 + proconio) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1 ms / 2,000 ms | 
| コード長 | 893 bytes | 
| コンパイル時間 | 12,930 ms | 
| コンパイル使用メモリ | 383,832 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-22 11:39:54 | 
| 合計ジャッジ時間 | 13,809 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 | 
ソースコード
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 % 10 {
        1 => "st",
        2 => "nd",
        3 => "rd",
        _ => "th"
    };
    println!("{}{}", order, postfix);
}
            
            
            
        