結果

問題 No.1043 直列大学
ユーザー Ricky_ponRicky_pon
提出日時 2019-11-14 00:47:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,783 bytes
コンパイル時間 1,706 ms
コンパイル使用メモリ 167,620 KB
実行使用メモリ 161,152 KB
最終ジャッジ日時 2024-05-02 14:44:45
合計ジャッジ時間 12,918 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
13,696 KB
testcase_01 AC 4 ms
6,784 KB
testcase_02 AC 10 ms
12,928 KB
testcase_03 AC 5 ms
6,784 KB
testcase_04 AC 5 ms
6,784 KB
testcase_05 AC 5 ms
6,912 KB
testcase_06 AC 4 ms
6,784 KB
testcase_07 AC 7 ms
9,856 KB
testcase_08 AC 8 ms
9,856 KB
testcase_09 AC 154 ms
83,456 KB
testcase_10 AC 772 ms
99,072 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 122 ms
134,912 KB
testcase_14 AC 132 ms
142,848 KB
testcase_15 AC 144 ms
155,904 KB
testcase_16 AC 126 ms
139,648 KB
testcase_17 AC 94 ms
102,784 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 196 ms
121,600 KB
testcase_22 AC 192 ms
127,232 KB
testcase_23 AC 279 ms
159,872 KB
testcase_24 AC 101 ms
113,024 KB
testcase_25 AC 121 ms
133,248 KB
testcase_26 AC 140 ms
142,720 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
typedef vector<lint> poly;

const lint mod = 1e9 + 7;
const lint INF = mod * mod;
const int MAX = 100010;

lint dpv[110][MAX], dpr[110][MAX];

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int v[n], r[m];
    rep(i, n) scanf("%d", &v[i]);
    rep(i, m) scanf("%d", &r[i]);
    lint a, b;
    scanf("%lld%lld", &a, &b);

    rep(i, n+1)rep(j, MAX) dpv[i][j] = 0;
    rep(i, m+1)rep(j, MAX) dpr[i][j] = 0;
    dpv[0][0] = 1;
    rep(i, n)rep(j, MAX)if(dpv[i][j]){
        dpv[i+1][j] += dpv[i][j];
        if(dpv[i+1][j] >= mod) dpv[i+1][j] -= mod;
        if(j+v[i] < MAX){
            dpv[i+1][j+v[i]] += dpv[i][j];
            if(dpv[i+1][j+v[i]] >= mod) dpv[i+1][j+v[i]] -= mod;
        }
    }
    dpr[0][0] = 1;
    rep(i, m)rep(j, MAX)if(dpr[i][j]){
        dpr[i+1][j] += dpr[i][j];
        if(dpr[i+1][j] >= mod) dpr[i+1][j] -= mod;
        if(j+r[i] < MAX){
            dpr[i+1][j+r[i]] += dpr[i][j];
            if(dpr[i+1][j+r[i]] >= mod) dpr[i+1][j+r[i]] -= mod;
        }
    }

    lint vsum[MAX];
    vsum[0] = 0;
    rep(i, MAX-1) vsum[i+1] = (vsum[i] + dpv[n][i]) % mod;

    lint ans = 0;
    For(i, 1, MAX)if(dpr[m][i]){
        lint L = a*(lint)i, R = b*(lint)i + 1;
        if(L >= MAX) break;
        For(j, L, R){
            ans += dpv[n][j] * dpr[m][i];
            if(ans >= mod) ans %= mod;
        }
    }
    printf("%lld\n", ans);
}
0