結果

問題 No.1722 [Cherry 3rd Tune C] In my way
ユーザー seinyan
提出日時 2021-10-29 22:05:08
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 773 bytes
コンパイル時間 12,285 ms
コンパイル使用メモリ 401,776 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-07 11:23:27
合計ジャッジ時間 13,373 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io;
fn main() {
    let nm = input_nums();
    let (_n, _m) = (nm[0], nm[1]);
    let x = input_nums();
    let mut y = input_nums();
    let mut xstep: Vec<i32> = Vec::new();
    y.sort();

    for xi in &x {
        xstep.push(get_step(*xi, &y));
    }

    for step in xstep {
        if step == -1 {
            println!("Infinity");
        } else {
            println!("{}", step);
        }
    }
}

fn get_step(x: i32, y: &Vec<i32>) -> i32 {
    for yi in y {
        if *yi >= x {
            return *yi - x;
        }
    }
    -1
}

fn input_nums() -> Vec<i32> {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let mut v = Vec::new();
    for n in s.split_whitespace() {
        v.push(n.parse().unwrap());
    }
    v
}
0