結果
| 問題 |
No.9009 改行区切りで与えられる数値データの合計値を求める(テスト用)
|
| ユーザー |
|
| 提出日時 | 2020-07-29 08:30:40 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 3,000 ms |
| コード長 | 471 bytes |
| コンパイル時間 | 12,298 ms |
| コンパイル使用メモリ | 387,568 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2024-06-28 21:20:54 |
| 合計ジャッジ時間 | 14,131 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)]` on by default
ソースコード
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);
}