結果

問題 No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー 小松秀行小松秀行
提出日時 2020-07-29 08:16:06
言語 Rust
(1.77.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 441 bytes
コンパイル時間 5,171 ms
コンパイル使用メモリ 135,772 KB
実行使用メモリ 7,028 KB
最終ジャッジ日時 2023-09-11 07:09:12
合計ジャッジ時間 4,030 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 12 ms
5,968 KB
testcase_11 AC 12 ms
6,052 KB
testcase_12 AC 12 ms
5,992 KB
testcase_13 AC 12 ms
6,024 KB
testcase_14 AC 12 ms
6,376 KB
testcase_15 AC 13 ms
6,360 KB
testcase_16 AC 13 ms
7,028 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `n`
  --> 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

warning: 1 warning emitted

ソースコード

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