結果

問題 No.1043 直列大学
ユーザー Ackey_coderAckey_coder
提出日時 2020-10-06 03:23:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,440 bytes
コンパイル時間 1,699 ms
コンパイル使用メモリ 171,776 KB
実行使用メモリ 162,332 KB
最終ジャッジ日時 2023-09-27 06:20:19
合計ジャッジ時間 19,241 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
161,924 KB
testcase_01 AC 116 ms
161,808 KB
testcase_02 AC 118 ms
161,848 KB
testcase_03 AC 116 ms
162,024 KB
testcase_04 AC 115 ms
161,804 KB
testcase_05 AC 116 ms
161,872 KB
testcase_06 AC 116 ms
161,872 KB
testcase_07 AC 115 ms
161,816 KB
testcase_08 AC 116 ms
161,856 KB
testcase_09 AC 137 ms
161,756 KB
testcase_10 AC 140 ms
161,860 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 158 ms
161,848 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 147 ms
161,760 KB
testcase_28 AC 169 ms
161,760 KB
testcase_29 AC 141 ms
161,856 KB
testcase_30 AC 162 ms
161,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N, M, A, B;
    cin>> N >> M;
    vi V(N + 1, 0), R(M + 1, 0);
    REP(i, 1, N + 1) cin >> V[i];
    REP(i, 1, M + 1) cin >> R[i];
    cin >> A >> B;
    vvl DPV(101, vl(100010, 0));
    vvl DPR(101, vl(100010, 0));
    REP(i, 0, N + 1) DPV[i][0] = 1;
    REP(i, 0, M + 1) DPR[i][0] = 1;
    
    REP(j, 1, N + 1){
        REP(i, 1, 100001){
            if(i - V[j] >= 0) DPV[j][i] += DPV[j - 1][i - V[j]];
            DPV[j][i] += DPV[j - 1][i];
            DPV[j][i] %= mod;
        }
    } 
    REP(j, 1, M + 1){
        REP(i, 1, 100001){
            if(i - R[j] >= 0) DPR[j][i] += DPR[j - 1][i - R[j]];
            DPR[j][i] += DPR[j - 1][i];
            DPR[j][i] %= mod;
        }
    }
    vl sum(100010, 0);
    long long ans = 0;
    REP(i, 1, 100001){
        sum[i] = DPV[N][i] + sum[i - 1];
        sum[i] %= mod;
        //if(i < 20) cout << sum[i] << " ";
    }
    REP(i, 1, 100001){
        ans += DPR[M][i] * (((i * B < 100000) ? sum[i * B] : sum[100000]) - sum[i * A - 1]) + mod;
        ans %= mod;
    }
    cout << ans << endl;
}
0