結果

問題 No.1043 直列大学
ユーザー potoooooooopotoooooooo
提出日時 2020-05-01 22:38:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,048 bytes
コンパイル時間 1,849 ms
コンパイル使用メモリ 199,772 KB
実行使用メモリ 5,064 KB
最終ジャッジ日時 2023-08-26 15:22:37
合計ジャッジ時間 3,794 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,028 KB
testcase_01 AC 4 ms
4,864 KB
testcase_02 AC 5 ms
5,064 KB
testcase_03 AC 5 ms
4,852 KB
testcase_04 AC 4 ms
4,972 KB
testcase_05 AC 5 ms
4,964 KB
testcase_06 AC 4 ms
4,924 KB
testcase_07 AC 4 ms
4,944 KB
testcase_08 AC 5 ms
4,940 KB
testcase_09 AC 18 ms
4,872 KB
testcase_10 AC 21 ms
4,876 KB
testcase_11 AC 30 ms
4,972 KB
testcase_12 RE -
testcase_13 AC 28 ms
4,936 KB
testcase_14 AC 28 ms
5,064 KB
testcase_15 AC 31 ms
4,996 KB
testcase_16 AC 29 ms
4,936 KB
testcase_17 AC 22 ms
4,920 KB
testcase_18 AC 22 ms
4,928 KB
testcase_19 AC 27 ms
4,992 KB
testcase_20 AC 21 ms
5,064 KB
testcase_21 AC 25 ms
4,972 KB
testcase_22 AC 26 ms
4,872 KB
testcase_23 AC 31 ms
5,036 KB
testcase_24 AC 23 ms
4,948 KB
testcase_25 AC 26 ms
4,996 KB
testcase_26 AC 29 ms
4,940 KB
testcase_27 AC 15 ms
4,916 KB
testcase_28 AC 26 ms
4,948 KB
testcase_29 AC 11 ms
4,936 KB
testcase_30 AC 21 ms
4,928 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 (ri * b > A) continue;
        ans += dpr[ri] * (mod - dpv[ri*b+1]) % mod;
    }
    cout << ans % mod << "\n";
    return 0;
}
0