結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
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;
        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