結果

問題 No.1043 直列大学
ユーザー phsplsphspls
提出日時 2022-12-06 01:04:56
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,730 bytes
コンパイル時間 1,174 ms
コンパイル使用メモリ 167,260 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 22:28:30
合計ジャッジ時間 2,104 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 10 ms
5,376 KB
testcase_12 AC 21 ms
5,376 KB
testcase_13 RE -
testcase_14 AC 15 ms
5,376 KB
testcase_15 RE -
testcase_16 AC 16 ms
5,376 KB
testcase_17 AC 10 ms
5,376 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 19 ms
5,376 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 5 ms
5,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

const MOD: usize = 1e9 as usize + 7;
const LIMIT: usize = 100000;

fn main() {
    let mut nm = String::new();
    std::io::stdin().read_line(&mut nm).ok();
    let nm: Vec<usize> = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nm[0];
    let m = nm[0];
    let mut v = String::new();
    std::io::stdin().read_line(&mut v).ok();
    let v: Vec<usize> = v.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut r = String::new();
    std::io::stdin().read_line(&mut r).ok();
    let r: Vec<usize> = r.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut ab = String::new();
    std::io::stdin().read_line(&mut ab).ok();
    let ab: Vec<usize> = ab.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let a = ab[0];
    let b = ab[1];

    let mut vcnts = vec![0usize; LIMIT+1];
    vcnts[0] = 1;
    for i in 0..n {
        for j in (0..=LIMIT).rev() {
            if vcnts[j] == 0 { continue; }
            vcnts[j+v[i]] += vcnts[j];
            vcnts[j+v[i]] %= MOD;
        }
    }
    let mut rcnts = vec![0usize; LIMIT+1];
    rcnts[0] = 1;
    for i in 0..m {
        for j in (0..LIMIT).rev() {
            if rcnts[j] == 0 { continue; }
            rcnts[j+r[i]] += rcnts[j];
            rcnts[j+r[i]] %= MOD;
        }
    }
    for i in 0..LIMIT {
        rcnts[i+1] += rcnts[i];
        rcnts[i+1] %= MOD;
    }
    let mut result = 0usize;
    for v in 1..=LIMIT {
        if vcnts[v] == 0 { continue; }
        let right = v / a;
        let left = v / b + if v % b > 0 { 1 } else { 0 };
        result += vcnts[v] * (MOD + rcnts[right] - rcnts[left-1]) % MOD;
        result %= MOD;
    }
    println!("{}", result);
}
0