Submission #7382908


Source Code Expand

Copy
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let xs: Vec<usize> = (0..n).map(|_| sc.cin::<usize>() - 1).collect();
    let ys: Vec<usize> = (0..n).map(|_| sc.cin()).collect();
    let zs: Vec<usize> = (1..n).map(|_| sc.cin()).collect();
    let mut ans = 0;
    for i in 0..n {
        ans += ys[xs[i]];
        if i > 0 && xs[i - 1] + 1 == xs[i] {
            ans += zs[xs[i-1]];
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}

Submission Info

Submission Time
Task B - Buffet
User cympfh
Language Rust (1.15.1)
Score 200
Code Size 2347 Byte
Status
Exec Time 2 ms
Memory 4352 KB

Compile Error

warning: unknown lint: `unused_macros`, #[warn(unknown_lints)] on by default
 --> ./Main.rs:1:26
  |
1 | #![allow(unused_imports, unused_macros, dead_code)]
  |                          ^^^^^^^^^^^^^

Judge Result

Set Name Score / Max Score Test Cases
All 200 / 200 sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10
Sample 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 2 ms 4352 KB
sample_02 2 ms 4352 KB
sample_03 2 ms 4352 KB
testcase_01 2 ms 4352 KB
testcase_02 2 ms 4352 KB
testcase_03 2 ms 4352 KB
testcase_04 2 ms 4352 KB
testcase_05 2 ms 4352 KB
testcase_06 2 ms 4352 KB
testcase_07 2 ms 4352 KB
testcase_08 2 ms 4352 KB
testcase_09 2 ms 4352 KB
testcase_10 2 ms 4352 KB