結果

問題 No.1825 Except One
ユーザー phsplsphspls
提出日時 2022-10-13 23:07:47
言語 Rust
(1.77.0)
結果
AC  
実行時間 101 ms / 3,000 ms
コード長 950 bytes
コンパイル時間 959 ms
コンパイル使用メモリ 149,724 KB
実行使用メモリ 103,572 KB
最終ジャッジ日時 2023-09-08 19:17:01
合計ジャッジ時間 3,685 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 101 ms
103,556 KB
testcase_04 AC 45 ms
47,056 KB
testcase_05 AC 17 ms
19,100 KB
testcase_06 AC 4 ms
5,100 KB
testcase_07 AC 95 ms
95,652 KB
testcase_08 AC 94 ms
95,636 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 70 ms
70,844 KB
testcase_11 AC 27 ms
28,316 KB
testcase_12 AC 48 ms
49,700 KB
testcase_13 AC 30 ms
32,564 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 24 ms
26,168 KB
testcase_25 AC 30 ms
32,568 KB
testcase_26 AC 6 ms
7,420 KB
testcase_27 AC 79 ms
84,476 KB
testcase_28 AC 98 ms
103,572 KB
testcase_29 AC 5 ms
6,680 KB
testcase_30 AC 6 ms
7,476 KB
testcase_31 AC 16 ms
17,416 KB
testcase_32 AC 97 ms
99,624 KB
testcase_33 AC 5 ms
5,896 KB
testcase_34 AC 98 ms
103,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const MAXV: usize = 50*100;

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