結果

問題 No.1043 直列大学
ユーザー rodearodea
提出日時 2020-05-16 15:37:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,048 bytes
コンパイル時間 1,490 ms
コンパイル使用メモリ 115,788 KB
実行使用メモリ 83,376 KB
最終ジャッジ日時 2023-10-23 16:09:46
合計ジャッジ時間 5,035 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,648 KB
testcase_01 AC 5 ms
5,992 KB
testcase_02 AC 9 ms
9,144 KB
testcase_03 AC 5 ms
5,992 KB
testcase_04 AC 5 ms
5,992 KB
testcase_05 AC 5 ms
5,992 KB
testcase_06 AC 5 ms
5,992 KB
testcase_07 AC 7 ms
7,568 KB
testcase_08 AC 7 ms
7,568 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 91 ms
73,936 KB
testcase_15 AC 99 ms
80,856 KB
testcase_16 AC 89 ms
72,456 KB
testcase_17 AC 66 ms
54,096 KB
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 AC 46 ms
38,108 KB
testcase_28 WA -
testcase_29 AC 28 ms
24,796 KB
testcase_30 AC 65 ms
52,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m; cin>>n>>m;
    vector<int> v(n), r(m);
    for(int i=0; i<n; i++) cin>>v[i];
    for(int i=0; i<m; i++) cin>>r[i];
    int a, b; cin>>a>>b;

    vector<vector<int>> vdp(n+1, vector<int>(100010, 0));
    vdp[0][0] = 1;
    for(int i=0; i<n; i++){
        for(int j=0; j<=100000; j++){
            if(j - v[i] >= 0) vdp[i+1][j] += vdp[i][j-v[i]];
            vdp[i+1][j] += vdp[i][j];
        }
    }

    vector<vector<int>> rdp(m+1, vector<int>(100010, 0));
    rdp[0][0] = 1;
    for(int i=0; i<m; i++){
        for(int j=0; j<=100000; j++){
            if(j - r[i] >= 0) rdp[i+1][j] += rdp[i][j-r[i]];
            rdp[i+1][j] += rdp[i][j];
        }
    }

    vector<ll> rdp_sum(100010, 0);
    for(int i=1; i<=100000; i++){
        rdp_sum[i+1] = rdp_sum[i] + rdp[m][i];
    }

    ll ans = 0;
    for(int i=1; i<=100000; i++){
        if(vdp[n][i] == 0) continue;

        int lb = (i + b - 1) / b, ub = i / a;
        ans += (rdp_sum[ub+1] - rdp_sum[lb]) * vdp[n][i];
        ans %= MOD;
    }
    
    cout << ans << endl;

    return 0;
}
0