結果

問題 No.9009 改行区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー 小松秀行
提出日時 2020-07-29 08:30:40
言語 Rust
(1.93.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 35 ms / 3,000 ms
コード長 471 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 621 ms
コンパイル使用メモリ 206,964 KB
実行使用メモリ 7,840 KB
最終ジャッジ日時 2026-03-18 01:05:54
合計ジャッジ時間 2,340 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `x`
  --> src/main.rs:15:37
   |
15 |     let a: Vec<usize> = (0..n).map(|x| read_line()[0]).collect();
   |                                     ^ help: if this is intentional, prefix it with an underscore: `_x`
   |
   = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

ソースコード

diff #
raw source code

use std::fmt::Debug;
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
    where T: FromStr, <T as FromStr>::Err: Debug {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}


fn main() {
    let n: usize = read_line()[0];
    let a: Vec<usize> = (0..n).map(|x| read_line()[0]).collect();

    let sum: usize = a.iter().sum();
    println!("{}", sum);
}
0