結果

問題 No.1043 直列大学
ユーザー tarattata1tarattata1
提出日時 2020-05-01 22:19:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,396 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 82,804 KB
実行使用メモリ 5,876 KB
最終ジャッジ日時 2023-08-26 14:49:23
合計ジャッジ時間 2,634 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll dp[2][100005];

void calc(int n, const vector<int>& v, vector<ll>& v0)
{
    int prev = 0, curr = 1;
    int i,j;
    for (i = 0; i <= 100000; i++) {
        dp[0][i] = dp[1][i] = 0;
    }
    dp[0][0] = 1;
    for (i = 0; i < n; i++) {
        for (j = 0; j <= 100000; j++) {
            dp[curr][j] = 0;
        }
        for (j = 0; j <= 100000; j++) {
            if (dp[prev][j]) {
                dp[curr][j] = (dp[curr][j] + dp[prev][j]) % MOD;
                int j2 = j + v[i];
                dp[curr][j2] = (dp[curr][j2] + dp[prev][j]) % MOD;
            }
        }
        swap(prev, curr);
    }
    for (i = 0; i <= 100000; i++) {
        v0[i] = dp[prev][i];
    }
    return;
}

void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> v(n), r(m);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &v[i]);
    }
    for (i = 0; i < m; i++) {
        scanf("%d", &r[i]);
    }
    int a, b;
    scanf("%d%d", &a, &b);

    vector<ll> v0(100005);
    vector<ll> v1(100005);
    calc(n, v, v0);
    calc(m, r, v1);

#if 0
    vector<ll> sv0(100005);
    for (i = 0; i <= 100000; i++) {
        sv0[i + 1] = (sv0[i] + v0[i]) % MOD;
    }

    ll ans = 0;
    for (i = 1; i <= 100000; i++) {
        int lim0 = a * i, lim1 = MIN(100000, b * i);
        if (lim0 > 100000) continue;

        ll tmp0 = (sv0[lim1 + 1] - sv0[lim0] + MOD) % MOD;
        ll tmp = tmp0 * v1[i] % MOD;
        ans = (ans + tmp) % MOD;
    }
    printf("%lld\n", ans);
#endif
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}

0