結果

問題 No.1043 直列大学
ユーザー potoooooooopotoooooooo
提出日時 2020-05-01 22:39:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,060 bytes
コンパイル時間 2,622 ms
コンパイル使用メモリ 199,676 KB
実行使用メモリ 5,192 KB
最終ジャッジ日時 2023-08-24 05:50:36
合計ジャッジ時間 4,203 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,984 KB
testcase_01 AC 4 ms
4,876 KB
testcase_02 AC 6 ms
4,964 KB
testcase_03 AC 5 ms
4,964 KB
testcase_04 AC 5 ms
4,976 KB
testcase_05 AC 5 ms
5,012 KB
testcase_06 AC 5 ms
4,976 KB
testcase_07 AC 6 ms
5,044 KB
testcase_08 AC 5 ms
4,864 KB
testcase_09 AC 20 ms
5,004 KB
testcase_10 AC 23 ms
5,108 KB
testcase_11 AC 33 ms
5,192 KB
testcase_12 AC 35 ms
4,948 KB
testcase_13 AC 31 ms
5,040 KB
testcase_14 AC 31 ms
4,940 KB
testcase_15 AC 35 ms
4,972 KB
testcase_16 AC 31 ms
4,940 KB
testcase_17 AC 24 ms
4,984 KB
testcase_18 AC 24 ms
4,940 KB
testcase_19 AC 29 ms
4,884 KB
testcase_20 AC 24 ms
5,112 KB
testcase_21 AC 27 ms
5,044 KB
testcase_22 AC 28 ms
4,940 KB
testcase_23 AC 35 ms
5,108 KB
testcase_24 AC 26 ms
4,952 KB
testcase_25 AC 30 ms
5,016 KB
testcase_26 AC 32 ms
4,936 KB
testcase_27 AC 18 ms
4,944 KB
testcase_28 AC 29 ms
4,872 KB
testcase_29 AC 12 ms
5,024 KB
testcase_30 AC 24 ms
4,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

constexpr int mod = 1000000007;
constexpr int N = 100;
constexpr int M = 1000;
constexpr long long A = N * M;
long long dpv[A+10], dpr[A+10];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<int> v(n), r(m);
    for (auto &x: v) cin >> x;
    for (auto &x: r) cin >> x;
    int a, b; cin >> a >> b;
    auto dp = [&](auto &v, auto &dpv) {
        dpv[0] = 1;
        for (auto &x: v) {
            for (int i = A; i >= x; i--) {
                dpv[i] = (dpv[i] + dpv[i-x]) % mod;
            }
        }
        
    };
    dp(v, dpv), dp(r, dpr);
    for (int i = A; i > 0; i--) {
        dpv[i-1] = (dpv[i-1] + dpv[i]) % mod; 
    }
    long long ans = 0;
    for (int ri = 1; ri <= A; ri++) {
        // ri * a <= v <= ri * b
        if (ri * a > A) break;
        ans += dpr[ri] * dpv[ri*a] % mod;
        if ((long long) ri * b > A) continue;
        ans += dpr[ri] * (mod - dpv[ri*b+1]) % mod;
    }
    cout << ans % mod << "\n";
    return 0;
}
0