結果

問題 No.1043 直列大学
ユーザー Ricky_ponRicky_pon
提出日時 2019-11-13 16:46:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,632 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 201,232 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2024-05-02 14:43:56
合計ジャッジ時間 3,864 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
7,552 KB
testcase_01 AC 6 ms
7,680 KB
testcase_02 AC 7 ms
7,680 KB
testcase_03 AC 6 ms
7,552 KB
testcase_04 AC 6 ms
7,552 KB
testcase_05 AC 6 ms
7,552 KB
testcase_06 AC 6 ms
7,552 KB
testcase_07 AC 7 ms
7,424 KB
testcase_08 AC 7 ms
7,552 KB
testcase_09 AC 20 ms
7,552 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 38 ms
7,552 KB
testcase_14 AC 40 ms
7,552 KB
testcase_15 AC 44 ms
7,552 KB
testcase_16 AC 39 ms
7,552 KB
testcase_17 AC 28 ms
7,552 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 31 ms
7,680 KB
testcase_25 AC 37 ms
7,552 KB
testcase_26 AC 39 ms
7,552 KB
testcase_27 WA -
testcase_28 AC 32 ms
7,552 KB
testcase_29 AC 13 ms
7,552 KB
testcase_30 AC 30 ms
7,552 KB
権限があれば一括ダウンロードができます

ソースコード

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[2][MAX], dpr[2][MAX], vsum[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, 2)rep(j, MAX) dpv[i][j] = 0;
    rep(i, 2)rep(j, MAX) dpr[i][j] = 0;
    dpv[0][0] = dpr[0][0] = 1;
    rep(i, n){
        rep(j, MAX)if(dpv[i&1][j]){
            (dpv[(i+1)&1][j] += dpv[i&1][j]) %= mod;
            if(j+v[i] < MAX) (dpv[(i+1)&1][j+v[i]] += dpv[i&1][j]) %= mod;
        }
        rep(j, MAX) dpv[i&1][j] = 0;
    }
    rep(i, m){
        rep(j, MAX)if(dpr[i&1][j]){
            (dpr[(i+1)&1][j] += dpr[i&1][j]) %= mod;
            if(j+r[i] < MAX) (dpr[(i+1)&1][j+r[i]] += dpr[i&1][j]) %= mod;
        }
        rep(j, MAX) dpr[i&1][j] = 0;
    }

    vsum[1] = 0;
    rep(i, MAX-2) vsum[i+2] = (vsum[i+1] + dpv[n&1][i+1]) % mod;
    lint ans = 0;
    For(i, 1, MAX)if(dpr[m&1][i]){
        lint L = a*i, R = b*i + 1;
        (ans += (vsum[min((lint)MAX, R)]+mod-vsum[min((lint)MAX, L)])%mod * dpr[m&1][i] % mod) %= mod;
    }
    printf("%lld\n", ans);
}
0