結果
問題 | No.1618 Convolution? |
ユーザー | uw_yu1rabbit |
提出日時 | 2021-08-26 15:55:23 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 86 ms / 2,000 ms |
コード長 | 3,084 bytes |
コンパイル時間 | 10,985 ms |
コンパイル使用メモリ | 402,036 KB |
実行使用メモリ | 19,772 KB |
最終ジャッジ日時 | 2024-11-18 09:19:04 |
合計ジャッジ時間 | 17,685 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 57 ms
15,612 KB |
testcase_03 | AC | 66 ms
17,132 KB |
testcase_04 | AC | 54 ms
12,004 KB |
testcase_05 | AC | 5 ms
5,248 KB |
testcase_06 | AC | 73 ms
17,684 KB |
testcase_07 | AC | 72 ms
16,712 KB |
testcase_08 | AC | 54 ms
12,500 KB |
testcase_09 | AC | 86 ms
18,640 KB |
testcase_10 | AC | 61 ms
15,420 KB |
testcase_11 | AC | 83 ms
18,020 KB |
testcase_12 | AC | 85 ms
19,772 KB |
testcase_13 | AC | 84 ms
18,864 KB |
testcase_14 | AC | 82 ms
19,100 KB |
testcase_15 | AC | 85 ms
19,224 KB |
testcase_16 | AC | 83 ms
19,100 KB |
コンパイルメッセージ
warning: constant `INF` is never used --> src/main.rs:110:7 | 110 | const INF:i64 = 1i64 << 60; | ^^^ | = note: `#[warn(dead_code)]` on by default
ソースコード
#[allow(dead_code)] fn solve(read: &mut snio::Reader<std::io::StdinLock<'_>>) { let n = read.usize(); let a:Vec<_> = (0..n).map(|_| read.i64()).collect(); let b:Vec<_> = (0..n).map(|_| read.i64()).collect(); let mut sum = vec![0;n]; let mut ss = 0; for i in 0..n { sum[i] = a[i] + b[i]; ss += sum[i]; } let mut d = vec![0;1 + n]; for i in 0..n { d[i + 1] = d[i] + sum[i]; } //println!("{:?}",d); let mut c = vec![0;2 * n]; for i in 1..n + 1 { c[i] = c[i - 1] + d[i]; } //println!("{:?}",sum); //println!("{:?}",c); for i in 0..n - 1 { c[n + 1 + i] = c[n + i] + ss - (n as i64 + 1) * (a[i] + b[i]); ss -= a[i] + b[i]; } for i in 0..2 * n { if i < 2 * n - 1 { print!("{} ",c[i]); }else { println!("{}",c[i]); } } } //use proconio::input; fn main() { let t = std::io::stdin(); let mut read = snio::Reader::new(t.lock()); let n = 1; for _ in 0..n { solve(&mut read); } } #[allow(dead_code)] pub mod snio { pub struct Reader<R: std::io::BufRead> { reader: R, buf: std::collections::VecDeque<String>, } impl<R: std::io::BufRead> Reader<R> { pub fn new(reader: R) -> Self { Self { reader, buf: std::collections::VecDeque::new(), } } fn load(&mut self) { while self.buf.is_empty() { let mut s = String::new(); let length = self.reader.read_line(&mut s).unwrap(); if length == 0 { break; } self.buf.extend(s.split_whitespace().map(|s| s.to_owned())); } } pub fn string(&mut self) -> String { self.load(); self.buf.pop_front().unwrap_or_else(|| panic!("input ended")) } pub fn char(&mut self) -> char { let string = self.string(); let mut chars = string.chars(); let res = chars.next().unwrap(); assert!(chars.next().is_none(), "invalid input!"); res } pub fn chars(&mut self) -> Vec<char> { self.read::<String>().chars().collect() } pub fn read<T: std::str::FromStr>(&mut self) -> T where <T as ::std::str::FromStr>::Err: ::std::fmt::Debug, { self.string().parse::<T>().expect("Failed to parse the input.") } } macro_rules! definition_of_reader_of_numbers { ($($ty:tt,)*) => { impl <R:std::io::BufRead> Reader<R> { $( #[inline] pub fn $ty (&mut self) -> $ty { self.read::<$ty>() } )* } } } definition_of_reader_of_numbers! { u8,u16,u32,u64,usize, i8,i16,i32,i64,isize, f32,f64, } } const INF:i64 = 1i64 << 60;