結果

問題 No.9001 標準入出力の練習問題(テスト用)
ユーザー dyundyun
提出日時 2017-12-28 10:40:44
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 556 bytes
コンパイル時間 16,336 ms
コンパイル使用メモリ 391,548 KB
実行使用メモリ 6,816 KB
最終ジャッジ日時 2024-06-01 05:29:46
合計ジャッジ時間 14,084 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{stdin, BufRead};
use std::str::FromStr;

fn read_lines() -> Vec<String> {
    let stdin = stdin();
    let lines = stdin.lock().lines().map(|l| l.unwrap()).collect();
    lines
}

fn to_nums<T>(line: &str) -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: std::fmt::Debug,
{
    line.split_whitespace()
        .map(|n| n.parse::<T>().unwrap())
        .collect()
}

fn main() {
    let lines = read_lines();
    let nums = to_nums::<isize>(&lines[0]);
    let ans = nums.iter().sum::<isize>();
    println!("{} {}", ans, &lines[1]);
}
0