結果

問題 No.1043 直列大学
ユーザー けーむけーむ
提出日時 2020-05-12 14:42:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,644 bytes
コンパイル時間 1,550 ms
コンパイル使用メモリ 167,988 KB
実行使用メモリ 4,696 KB
最終ジャッジ日時 2023-10-11 13:32:29
合計ジャッジ時間 3,094 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    ll n, m;
    cin >> n >> m;
    vector<ll> v(n);
    ll sumv = 0;
    rep(i, n) {
        cin >> v[i];
        sumv += v[i];
    }
    vector<ll> r(m);
    ll sumr = 0;
    rep(i, m) {
        cin >> r[i];
        sumr += r[i];
    }
    ll a, b;
    cin >> a >> b;
    vector<ll> vdp(sumv + 1, 0);
    vdp[0] = 1;
    rep(i, n) {
        rreps(j, v[i], sumv + 1) {
            vdp[j] = (vdp[j] + vdp[j - v[i]]) % mod;
        }
    }
    rep(i, sumv + 1) {
        if (i > 0) vdp[i] += vdp[i - 1];
    }
    vector<ll> rdp(sumr + 1, 0);
    rdp[0] = 1;
    rep(i, m) {
        rreps(j, r[i], sumr + 1) {
            rdp[j] = (rdp[j] + rdp[j - r[i]]) % mod;
        }
    }
    ll ans = 0;
    reps(i, 1, sumr + 1) {
        ll l = a * i;
        ll r = b * i;
        if (l > sumv) continue;
        ll lv = (l == 0) ? 0 : vdp[l - 1];
        ll rv = (r > sumv) ? vdp[sumv] : vdp[r];
        ll cnt = max(0LL, rv - lv);
        ans = (ans + rdp[i] * cnt) % mod;
    }
    cout << ans << endl;
    return 0;
}
0