結果

問題 No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー iwot
提出日時 2019-04-23 10:35:29
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 13,902 ms
コンパイル使用メモリ 392,920 KB
実行使用メモリ 6,912 KB
最終ジャッジ日時 2024-10-13 07:00:00
合計ジャッジ時間 15,639 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `num`
  --> src/main.rs:17:9
   |
17 |     let num: i32 = read();
   |         ^^^ help: if this is intentional, prefix it with an underscore: `_num`
   |
   = note: `#[warn(unused_variables)]` on by default

ソースコード

diff #

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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 num: i32 = read();
    let numbers: Vec<i64> = read_vec();
    print!("{}", numbers.iter().fold(0, |sum, i| sum + i));
}
0