結果

問題 No.1825 Except One
ユーザー fukafukatanifukafukatani
提出日時 2022-02-11 12:17:06
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 1,628 bytes
コンパイル時間 5,433 ms
コンパイル使用メモリ 154,224 KB
実行使用メモリ 215,576 KB
最終ジャッジ日時 2023-09-09 13:22:43
合計ジャッジ時間 11,523 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 8 ms
4,376 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();
    let max_sum = n * 100;
    let mut dp = vec![vec![vec![0i64; 101]; max_sum + 1]; n + 1];
    dp[0][0][0] = 1;
    for aa in a {
        for prev_used in (0..n).rev() {
            for prev_sum in 0..max_sum {
                if prev_sum + aa > max_sum {
                    break;
                }
                for prev_max in 0..=100 {
                    dp[prev_used + 1][prev_sum + aa][max(prev_max, aa)] +=
                        dp[prev_used][prev_sum][prev_max];
                }
            }
        }
    }
    let mut ans = 0;
    for used in 2..=n {
        let mut coef = 0;
        while coef <= used * 100 {
            let operated = coef / (used - 1);
            for prev_max in 0..=min(operated, 100) {
                ans += dp[used][coef][prev_max];
            }
            coef += used - 1;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
0