結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー pekempeypekempey
提出日時 2019-12-12 02:03:08
言語 Rust
(1.77.0)
結果
AC  
実行時間 543 ms / 2,500 ms
コード長 1,653 bytes
コンパイル時間 1,041 ms
コンパイル使用メモリ 151,908 KB
実行使用メモリ 10,972 KB
最終ジャッジ日時 2023-09-06 13:42:36
合計ジャッジ時間 7,147 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 227 ms
7,996 KB
testcase_12 AC 297 ms
8,232 KB
testcase_13 AC 213 ms
7,520 KB
testcase_14 AC 28 ms
4,380 KB
testcase_15 AC 183 ms
5,380 KB
testcase_16 AC 378 ms
8,064 KB
testcase_17 AC 49 ms
4,380 KB
testcase_18 AC 482 ms
10,348 KB
testcase_19 AC 166 ms
5,696 KB
testcase_20 AC 31 ms
4,380 KB
testcase_21 AC 5 ms
4,380 KB
testcase_22 AC 9 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 235 ms
6,640 KB
testcase_25 AC 383 ms
10,724 KB
testcase_26 AC 444 ms
10,908 KB
testcase_27 AC 430 ms
9,820 KB
testcase_28 AC 543 ms
10,972 KB
testcase_29 AC 247 ms
7,008 KB
testcase_30 AC 63 ms
4,376 KB
testcase_31 AC 10 ms
4,380 KB
testcase_32 AC 407 ms
9,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(non_snake_case)]

fn main() {
#[allow(unused_imports)]
    use std::cmp::{min, max};
    use std::io::{Read, Write, BufWriter};
    let mut a = Vec::new();
    std::io::stdin().read_to_end(&mut a).unwrap();
    let a = String::from_utf8(a).unwrap();
    let mut a = a.split_whitespace();
    let mut b = BufWriter::new(std::io::stdout());
    macro_rules! yomu { () => (a.next().unwrap().parse().unwrap()) }
    macro_rules! kaku { ($($arg:tt)*) => (writeln!(b, $($arg)*).unwrap()) }

    let N: usize = yomu!();
    let mut A: Vec<i32> = Vec::new();
    let mut B: Vec<i32> = Vec::new();
    let mut D: Vec<i32> = Vec::new();
    for _ in 0..N+1 { A.push(yomu!()); }
    for _ in 0..N+1 { B.push(yomu!()); }
    for _ in 0..N { D.push(yomu!()); }
    D.sort();
    D.reverse();

    let mut l = 0;
    let mut r = N + 1;
    while r - l > 1 {
        let m: usize = (l + r) / 2;
        let mut dp = vec![vec![false; m+1]; m+1];
        dp[0][0] = true;
        for i in 0..m {
            for j in 0..m {
                if i+j >= m { break }
                if !dp[i][j] { continue }
                if A[i+1] + B[j] >= D[N-m+i+j] {
                    dp[i+1][j] = true;
                }
                if A[i] + B[j+1] >= D[N-m+i+j] {
                    dp[i][j+1] = true;
                }
            }
        }
        let mut saidai = 0;
        for i in 0..m+1 {
            for j in 0..m+1 {
                if dp[i][j] {
                    saidai = max(saidai, i+j);
                }
            }
        }
        if saidai == m {
            l = m;
        } else {
            r = m;
        }
    }
    kaku!("{}", l);
}
0