結果

問題 No.1208 anti primenumber game
ユーザー ikdikd
提出日時 2020-09-02 20:52:50
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,639 bytes
コンパイル時間 14,577 ms
コンパイル使用メモリ 385,772 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 15:25:04
合計ジャッジ時間 16,192 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,820 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 19 ms
6,940 KB
testcase_16 AC 20 ms
6,940 KB
testcase_17 AC 19 ms
6,944 KB
testcase_18 AC 19 ms
6,940 KB
testcase_19 AC 20 ms
6,944 KB
testcase_20 AC 19 ms
6,940 KB
testcase_21 WA -
testcase_22 AC 21 ms
6,940 KB
testcase_23 WA -
testcase_24 AC 58 ms
6,940 KB
testcase_25 AC 58 ms
6,944 KB
testcase_26 AC 55 ms
6,944 KB
testcase_27 AC 55 ms
6,940 KB
testcase_28 AC 55 ms
6,940 KB
testcase_29 AC 55 ms
6,940 KB
testcase_30 WA -
testcase_31 AC 19 ms
6,940 KB
testcase_32 WA -
testcase_33 AC 20 ms
6,940 KB
testcase_34 AC 19 ms
6,940 KB
testcase_35 AC 19 ms
6,944 KB
testcase_36 AC 15 ms
6,944 KB
testcase_37 AC 19 ms
6,940 KB
testcase_38 WA -
testcase_39 AC 46 ms
6,940 KB
testcase_40 AC 54 ms
6,940 KB
testcase_41 AC 22 ms
6,940 KB
testcase_42 AC 23 ms
6,940 KB
testcase_43 WA -
testcase_44 AC 23 ms
6,944 KB
testcase_45 WA -
testcase_46 AC 18 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

macro_rules! chmax {
    ($a:expr, $b:expr) => {
        $a = std::cmp::max($a, $b)
    };
}

fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let n: usize = rd.get();
    let m: i64 = rd.get();
    let a: Vec<i64> = (0..n).map(|_| rd.get()).collect();

    let sum = a.iter().sum::<i64>() - m * n as i64;

    let inf = std::i64::MAX / 2;
    let mut dp = vec![-inf; 2];
    dp[0] = 0;
    for x in a {
        let mut nxt = vec![-inf; 2];
        if dp[1] != -inf {
            if x >= 2 {
                nxt[1] = dp[1] + 1 - m;
            }
            nxt[0] = dp[1];
        }

        if dp[0] != inf {
            chmax!(nxt[1], dp[0] + x - m);
            if x >= 2 {
                chmax!(nxt[0], dp[0] + x - 1);
            }
        }
        dp = nxt;
    }
    let max = dp.iter().max().unwrap();
    println!("{}", if max * 2 > sum { "First" } else { "Second" });
}
0