結果

問題 No.143 豆
ユーザー cra77756176
提出日時 2022-11-21 01:03:40
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 527 bytes
コンパイル時間 17,905 ms
コンパイル使用メモリ 378,080 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-21 21:03:31
合計ジャッジ時間 12,645 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{self, BufRead};

fn main() {
    let input = io::stdin()
        .lock()
        .lines()
        .flat_map(|l| {
            l.unwrap()
                .split_whitespace()
                .map(|n| n.parse::<i64>().unwrap())
                .collect::<Vec<_>>()
        })
        .collect::<Vec<_>>();

    let n_beans = input[0] * input[1];
    let n_consume = input[3..].iter().sum::<i64>();

    match n_beans - n_consume {
        rem if rem >= 0 => println!("{}", rem),
        _ => println!("-1"),
    }
}
0