結果

問題 No.1043 直列大学
ユーザー noriocnorioc
提出日時 2020-05-02 04:15:44
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,318 bytes
コンパイル時間 1,317 ms
コンパイル使用メモリ 161,660 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2023-09-04 07:38:55
合計ジャッジ時間 3,664 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,416 KB
testcase_01 AC 5 ms
7,096 KB
testcase_02 AC 8 ms
6,828 KB
testcase_03 AC 4 ms
6,132 KB
testcase_04 AC 4 ms
6,044 KB
testcase_05 AC 4 ms
6,876 KB
testcase_06 AC 4 ms
6,328 KB
testcase_07 AC 6 ms
6,908 KB
testcase_08 AC 6 ms
6,860 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 63 ms
5,832 KB
testcase_12 WA -
testcase_13 AC 58 ms
6,412 KB
testcase_14 AC 61 ms
5,800 KB
testcase_15 AC 66 ms
5,768 KB
testcase_16 AC 60 ms
5,776 KB
testcase_17 AC 44 ms
6,824 KB
testcase_18 WA -
testcase_19 AC 56 ms
5,776 KB
testcase_20 AC 43 ms
5,824 KB
testcase_21 AC 53 ms
6,644 KB
testcase_22 AC 55 ms
5,808 KB
testcase_23 AC 68 ms
6,120 KB
testcase_24 AC 49 ms
6,308 KB
testcase_25 AC 57 ms
5,808 KB
testcase_26 AC 62 ms
7,168 KB
testcase_27 AC 31 ms
5,884 KB
testcase_28 AC 57 ms
6,616 KB
testcase_29 AC 20 ms
5,884 KB
testcase_30 AC 43 ms
6,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

const MOD = 10^^9 + 7;

long calc(int[] v, int[] r, int a, int b) {
    const N = 110000;

    // dp1[i] = 電圧の和が i となる組み合わせの数
    auto dp1 = new long[N];
    // dp2[i] = 抵抗の和が i となる組み合わせの数
    auto dp2 = new long[N];

    dp1[0] = dp2[0] = 1;
    foreach (i; 0..v.length) {
        for (int j = N-1; j >= v[i]; j--) {
            dp1[j] += dp1[j - v[i]];
            dp1[j] %= MOD;
        }
    }
    foreach (i; 0..r.length) {
        for (int j = N-1; j >= r[i]; j--) {
            dp2[j] += dp2[j - r[i]];
            dp2[j] %= MOD;
        }
    }

    auto acc = new long[N + 1];
    foreach (i; 0..N) acc[i+1] = acc[i] + dp1[i];

    long ans = 0;
    foreach (i; 1..N) {
        auto lo = min(N, cast(long)a * i);
        auto hi = min(N, cast(long)b * i + 1);
        ans = (ans + dp2[i] * (acc[hi] - acc[lo])) % MOD;
    }
    return ans;
}

void main() {
    int n, m; scan(n, m);
    auto v = readints;
    auto r = readints;
    int a, b; scan(a, b);
    writeln(calc(v, r, a, b));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
0