結果

問題 No.586 ダブルブッキング
ユーザー hatoo
提出日時 2017-11-03 22:24:35
言語 Rust
(1.30.1)
結果
AC  
実行時間 2 ms
コード長 2,513 Byte
コンパイル時間 1,186 ms
使用メモリ 1,100 KB
最終ジャッジ日時 2018-11-10 10:18:29

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
sample1.txt AC 2 ms
1,092 KB
sample2.txt AC 2 ms
1,092 KB
sample3.txt AC 1 ms
1,088 KB
test1.txt AC 2 ms
1,100 KB
test2.txt AC 1 ms
1,088 KB
test3.txt AC 2 ms
1,092 KB
test4.txt AC 2 ms
1,084 KB
test5.txt AC 2 ms
1,092 KB
テストケース一括ダウンロード

ソースコード

diff #
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap};
#[allow(unused_imports)]
use std::iter::FromIterator;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let p1: usize = util::get();
    let p2: usize = util::get();
    let n: usize = util::get();
    let rs: Vec<usize> = (0..n).map(|_| util::get()).collect();

    let mut arr = vec![false; 1000];
    let mut ans = 0;

    for &r in &rs {
        if arr[r] {
            ans += p1 + p2;
        } else {
            arr[r] = true;
        }
    }

    println!("{}", ans);
}
0