結果

問題 No.9009 改行区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー maimai
提出日時 2021-04-21 02:05:41
言語 Rust
(1.77.0)
結果
AC  
実行時間 39 ms / 3,000 ms
コード長 766 bytes
コンパイル時間 705 ms
コンパイル使用メモリ 147,516 KB
実行使用メモリ 5,820 KB
最終ジャッジ日時 2023-09-17 09:22:52
合計ジャッジ時間 2,094 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 AC 27 ms
4,376 KB
testcase_10 AC 37 ms
5,108 KB
testcase_11 AC 37 ms
5,056 KB
testcase_12 AC 38 ms
5,112 KB
testcase_13 AC 39 ms
5,264 KB
testcase_14 AC 36 ms
5,316 KB
testcase_15 AC 36 ms
5,308 KB
testcase_16 AC 39 ms
5,820 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `collections::*`
 --> Main.rs:1:11
  |
1 | use std::{collections::*, io::Read};
  |           ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: 1 warning emitted

ソースコード

diff #

use std::{collections::*, io::Read};

fn take_token<R: std::io::BufRead>(cin: &mut R) -> String {
    cin.bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>()
}
#[allow(unused)]
macro_rules! scan {
    ($io:expr => $t:ty) => (take_token(&mut $io).parse::<$t>().unwrap());
    ($io:expr => $t:tt * $n:expr) => ((0..$n).map(|_| scan!($io => $t)).collect::<Vec<_>>());
    ($io:expr => $($t:tt),*) => (($(scan!($io => $t)),*));
}

fn main() {
    solve(std::io::stdin().lock())
}

fn solve<R: std::io::BufRead>(mut cin: R) {
    let n = scan!(cin => i32);
    let aa = scan!(cin => i64 * n);
    let total = aa.iter().sum::<i64>();
    println!("{}", total);
}
0