結果

問題 No.1043 直列大学
ユーザー StrorkisStrorkis
提出日時 2020-05-02 00:14:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,167 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 70,900 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 17:25:04
合計ジャッジ時間 1,645 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 3 ms
4,376 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 2 ms
4,380 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

const int MOD = 1000000007;
const long long DP_MAX = 10000;

int main() {
    int N, M;
    std::cin >> N >> M;

    std::vector<int> V(N), R(M);
    for (int i = 0; i < N; i++) std::cin >> V[i];
    for (int i = 0; i < M; i++) std::cin >> R[i];

    long long A, B;
    std::cin >> A >> B;

    std::vector<long long> dp_V(DP_MAX + 1), dp_R(DP_MAX + 1);
    dp_V[0] = dp_R[0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = DP_MAX; j >= 0; j--) {
            if (j + V[i] <= DP_MAX) {
                dp_V[j + V[i]] += dp_V[j];
                dp_V[j + V[i]] %= MOD;
            }
            if (j + R[i] <= DP_MAX) {
                dp_R[j + R[i]] += dp_R[j];
                dp_R[j + R[i]] %= MOD;
            }
        }
    }

    for (int i = 0; i < DP_MAX; i++)
        dp_V[i + 1] += dp_V[i];

    int ans = 0;
    for (long long i = 1; i <= DP_MAX; i++) {
        long long left = i * A - 1;
        if (left >= DP_MAX) break;
        long long right = std::min(DP_MAX, i * B);
        ans += (dp_V[right] - dp_V[left] + MOD) % MOD * dp_R[i] % MOD;
        ans %= MOD;
    }
    std::cout << ans << "\n";
}
0