結果
| 問題 |
No.1618 Convolution?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-20 22:19:53 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 2,000 ms |
| コード長 | 1,908 bytes |
| コンパイル時間 | 21,505 ms |
| コンパイル使用メモリ | 396,380 KB |
| 実行使用メモリ | 9,728 KB |
| 最終ジャッジ日時 | 2024-10-14 04:11:00 |
| 合計ジャッジ時間 | 21,956 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 |
ソースコード
use std::cmp::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
($($r:tt)*) => {
let stdin = std::io::stdin();
let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
let mut next = move || -> String{
bytes.by_ref().map(|r|r.unwrap() as char)
.skip_while(|c|c.is_whitespace())
.take_while(|c|!c.is_whitespace())
.collect()
};
input_inner!{next, $($r)*}
};
}
macro_rules! input_inner {
($next:expr) => {};
($next:expr,) => {};
($next:expr, $var:ident : $t:tt $($r:tt)*) => {
let $var = read_value!($next, $t);
input_inner!{$next $($r)*}
};
}
macro_rules! read_value {
($next:expr, ( $($t:tt),* )) => { ($(read_value!($next, $t)),*) };
($next:expr, [ $t:tt ; $len:expr ]) => {
(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
};
($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}
fn main() {
let out = std::io::stdout();
let mut out = BufWriter::new(out.lock());
macro_rules! puts {($($format:tt)*) => (let _ = write!(out,$($format)*););}
#[allow(unused)]
macro_rules! putvec {
($v:expr) => {
for i in 0..$v.len() {
puts!("{}{}", $v[i], if i + 1 == $v.len() {"\n"} else {" "});
}
}
}
input! {
n: usize,
a: [i64; n],
b: [i64; n],
}
let mut acc = vec![0; n + 1];
for i in 0..n {
acc[i + 1] = acc[i] + a[i] + b[i];
}
let mut ans = vec![0; 2 * n];
for i in 1..2 * n {
let hi = min(i, n);
let lo = max(i, n) - n;
ans[i] = ans[i - 1] + acc[hi] - acc[lo];
if i > n {
ans[i] -= (acc[lo] - acc[lo - 1]) * n as i64;
}
}
putvec!(ans);
}