結果

問題 No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー 小松秀行
提出日時 2020-07-29 08:16:06
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 441 bytes
コンパイル時間 12,532 ms
コンパイル使用メモリ 379,292 KB
実行使用メモリ 6,912 KB
最終ジャッジ日時 2024-06-28 21:20:37
合計ジャッジ時間 13,722 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `n`
  --> src/main.rs:14:9
   |
14 |     let n: usize = read_line()[0];
   |         ^ help: if this is intentional, prefix it with an underscore: `_n`
   |
   = note: `#[warn(unused_variables)]` on by default

ソースコード

diff #

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> = read_line();
    let sum: usize = a.iter().sum();
    println!("{}", sum);
}
0