結果

問題 No.1694 ZerOne
ユーザー phsplsphspls
提出日時 2022-10-19 23:20:45
言語 Rust
(1.77.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 790 bytes
コンパイル時間 1,151 ms
コンパイル使用メモリ 143,648 KB
実行使用メモリ 55,212 KB
最終ジャッジ日時 2023-09-12 10:46:19
合計ジャッジ時間 3,375 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 9 ms
9,196 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 10 ms
10,512 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 4 ms
4,516 KB
testcase_14 AC 11 ms
10,740 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 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 56 ms
55,212 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 54 ms
53,128 KB
testcase_24 AC 17 ms
15,716 KB
testcase_25 AC 17 ms
15,288 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 43 ms
42,280 KB
testcase_28 AC 9 ms
9,968 KB
testcase_29 AC 4 ms
4,376 KB
testcase_30 AC 9 ms
9,168 KB
testcase_31 AC 12 ms
12,052 KB
testcase_32 AC 17 ms
16,224 KB
testcase_33 AC 16 ms
15,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s = s.trim().chars().collect::<Vec<_>>();

    let n = s.len();
    let score = s.iter().enumerate().filter(|&(_, &c)| c == '1').map(|(i, _)| i+1).sum::<usize>();
    let one_cnt = s.iter().filter(|&&c| c == '1').count();
    let mut dp = vec![vec![vec![0usize; score+1]; one_cnt+1]; n+1];
    dp[0][0][0] = 1;
    for i in 0..n {
        for j in 0..=one_cnt {
            for k in 0..=score {
                if dp[i][j][k] == 0 { continue; }
                dp[i+1][j][k] += dp[i][j][k];
                if j+1 <= one_cnt && k+i+1 <= score {
                    dp[i+1][j+1][k+i+1] += dp[i][j][k];
                }
            }
        }
    }
    println!("{}", dp[n][one_cnt][score]);
}
0