結果

問題 No.143 豆
ユーザー iwot
提出日時 2019-04-23 21:22:39
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 520 bytes
コンパイル時間 12,831 ms
コンパイル使用メモリ 393,608 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-23 11:13:11
合計ジャッジ時間 13,799 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let bean: Vec<i32> = read_vec();
    let membebrs: Vec<i32> = read_vec();
    let total = bean[0] * bean[1];
    let result = total - membebrs.iter().fold(0, |sum, i| sum + i);
    if result >= 0 {
        println!("{}", result);
    } else {
        println!("-1");
    }
}
0