結果

問題 No.1825 Except One
ユーザー phsplsphspls
提出日時 2022-10-13 02:38:48
言語 Rust
(1.77.0)
結果
AC  
実行時間 99 ms / 3,000 ms
コード長 921 bytes
コンパイル時間 2,793 ms
コンパイル使用メモリ 139,512 KB
実行使用メモリ 103,592 KB
最終ジャッジ日時 2023-09-08 18:44:55
合計ジャッジ時間 5,008 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 99 ms
103,584 KB
testcase_04 AC 44 ms
47,052 KB
testcase_05 AC 17 ms
19,112 KB
testcase_06 AC 4 ms
5,120 KB
testcase_07 AC 91 ms
95,620 KB
testcase_08 AC 92 ms
95,656 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 68 ms
70,760 KB
testcase_11 AC 27 ms
28,332 KB
testcase_12 AC 47 ms
49,724 KB
testcase_13 AC 31 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,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 24 ms
26,248 KB
testcase_25 AC 29 ms
32,524 KB
testcase_26 AC 6 ms
7,488 KB
testcase_27 AC 77 ms
84,540 KB
testcase_28 AC 95 ms
103,592 KB
testcase_29 AC 5 ms
6,716 KB
testcase_30 AC 6 ms
7,492 KB
testcase_31 AC 16 ms
17,528 KB
testcase_32 AC 96 ms
99,620 KB
testcase_33 AC 4 ms
5,896 KB
testcase_34 AC 96 ms
103,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const LIMIT: usize = 100*50;

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