結果

問題 No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー mai
提出日時 2021-04-21 01:41:59
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 1,001 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,562 ms
コンパイル使用メモリ 194,424 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-03-25 13:58:31
合計ジャッジ時間 6,017 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `collections::*`
 --> src/main.rs:1:30
  |
1 | use std::{borrow::BorrowMut, collections::*, io::Read};
  |                              ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default

ソースコード

diff #
raw source code

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

struct Scanner<R: std::io::BufRead>(R);

impl<R: std::io::BufRead> Scanner<R> {
    fn new(input: R) -> Self {
        Self(input)
    }
    fn take(&mut self) -> String {
        self.0
            .borrow_mut()
            .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) => ($io.take().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(Scanner::<std::io::StdinLock>::new(std::io::stdin().lock()))
}

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