結果

問題 No.1825 Except One
ユーザー phsplsphspls
提出日時 2022-10-26 23:21:11
言語 Rust
(1.77.0)
結果
AC  
実行時間 114 ms / 3,000 ms
コード長 923 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 150,052 KB
実行使用メモリ 103,572 KB
最終ジャッジ日時 2023-09-17 16:29:47
合計ジャッジ時間 3,830 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 60 ms
51,820 KB
testcase_04 AC 17 ms
15,652 KB
testcase_05 AC 5 ms
5,456 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 56 ms
48,336 KB
testcase_08 AC 58 ms
50,248 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 37 ms
31,932 KB
testcase_11 AC 7 ms
7,256 KB
testcase_12 AC 21 ms
18,824 KB
testcase_13 AC 11 ms
10,020 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 8 ms
8,744 KB
testcase_25 AC 5 ms
6,180 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 36 ms
33,876 KB
testcase_28 AC 97 ms
88,248 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 4 ms
5,024 KB
testcase_32 AC 66 ms
57,596 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 114 ms
103,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 summary = a.iter().sum::<usize>();
    let mut dp = vec![vec![vec![0usize; summary+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..=summary {
                if dp[i][j][k] == 0 { continue; }
                dp[i+1][j][k] += dp[i][j][k];
                let nval = k+a[i];
                dp[i+1][j+1][nval] += dp[i][j][k];
                if j+1 >= 2 && nval%j == 0 && nval/j >= a[i] {
                    result += dp[i][j][k];
                }
            }
        }
    }
    println!("{}", result);
}
0