結果

問題 No.1825 Except One
ユーザー phsplsphspls
提出日時 2022-10-19 12:20:03
言語 Rust
(1.77.0)
結果
AC  
実行時間 102 ms / 3,000 ms
コード長 1,021 bytes
コンパイル時間 1,352 ms
コンパイル使用メモリ 143,240 KB
実行使用メモリ 103,572 KB
最終ジャッジ日時 2023-09-12 02:14:20
合計ジャッジ時間 4,432 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 102 ms
103,572 KB
testcase_04 AC 45 ms
47,068 KB
testcase_05 AC 18 ms
19,020 KB
testcase_06 AC 4 ms
5,056 KB
testcase_07 AC 94 ms
95,568 KB
testcase_08 AC 95 ms
95,612 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 71 ms
70,828 KB
testcase_11 AC 27 ms
28,256 KB
testcase_12 AC 48 ms
49,720 KB
testcase_13 AC 31 ms
32,556 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 3 ms
4,384 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 3 ms
4,384 KB
testcase_21 AC 1 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 24 ms
26,220 KB
testcase_25 AC 30 ms
32,548 KB
testcase_26 AC 6 ms
7,432 KB
testcase_27 AC 80 ms
84,548 KB
testcase_28 AC 99 ms
103,532 KB
testcase_29 AC 5 ms
6,668 KB
testcase_30 AC 6 ms
7,476 KB
testcase_31 AC 16 ms
17,468 KB
testcase_32 AC 98 ms
99,616 KB
testcase_33 AC 4 ms
5,816 KB
testcase_34 AC 99 ms
103,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const LIMIT: usize = 5000;

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let mut a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

    a.sort();
    let mut dp = vec![vec![vec![0usize; LIMIT+1]; n+1]; n+1];
    dp[0][0][0] = 1;
    let mut result = 0usize;
    for i in 0..n {
        for j in 0..n {
            for k in 0..=LIMIT {
                if dp[i][j][k] == 0 { continue; }
                dp[i+1][j][k] += dp[i][j][k];
                let ncnt = j+1;
                let summary = k+a[i];
                if summary <= LIMIT {
                    dp[i+1][ncnt][summary] += dp[i][j][k];
                    if j > 0 && summary % j == 0 && summary / j >= a[i] {
                        result += dp[i][j][k];
                    }
                }
            }
        }
    }
    println!("{}", result);
}
0