結果

問題 No.1043 直列大学
ユーザー hasegawa1hasegawa1
提出日時 2020-05-01 22:14:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,100 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 71,720 KB
実行使用メモリ 4,892 KB
最終ジャッジ日時 2023-08-26 14:26:08
合計ジャッジ時間 2,815 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,560 KB
testcase_01 AC 3 ms
4,728 KB
testcase_02 AC 5 ms
4,856 KB
testcase_03 AC 4 ms
4,716 KB
testcase_04 AC 3 ms
4,652 KB
testcase_05 AC 3 ms
4,564 KB
testcase_06 AC 3 ms
4,548 KB
testcase_07 AC 4 ms
4,892 KB
testcase_08 AC 4 ms
4,716 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 39 ms
4,720 KB
testcase_12 WA -
testcase_13 AC 33 ms
4,568 KB
testcase_14 AC 37 ms
4,728 KB
testcase_15 AC 42 ms
4,664 KB
testcase_16 AC 39 ms
4,620 KB
testcase_17 AC 30 ms
4,716 KB
testcase_18 WA -
testcase_19 AC 36 ms
4,672 KB
testcase_20 AC 29 ms
4,720 KB
testcase_21 AC 33 ms
4,548 KB
testcase_22 AC 34 ms
4,652 KB
testcase_23 AC 43 ms
4,736 KB
testcase_24 AC 28 ms
4,648 KB
testcase_25 AC 34 ms
4,724 KB
testcase_26 AC 36 ms
4,568 KB
testcase_27 AC 20 ms
4,616 KB
testcase_28 AC 34 ms
4,564 KB
testcase_29 AC 13 ms
4,720 KB
testcase_30 AC 25 ms
4,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <numeric>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int main(void) {
    int64_t N, M, A, B;
    cin >> N >> M;
    vector<int> V(N), R(M);
    for(int i=0; i<N; i++) {
        cin >> V[i];
    }
    for(int j=0; j<M; j++) {
        cin >> R[j];
    }
    cin >> A >> B;

    vector<int64_t> cntV(100000), cntR(100000);
    cntV[0] = 1;
    cntR[0] = 1;
    for(int i=0; i<N; i++) {
        for(int k=100000; k>=0; k--) {
            if(k+V[i] >= 100000) continue;
            cntV[k+V[i]] += cntV[k];
            cntV[k+V[i]] %= MOD;
        }
    }
    partial_sum(cntV.begin(), cntV.end(), cntV.begin());
    for(int j=0; j<M; j++) {
        for(int k=100000; k>=0; k--) {
            if(k+R[j] >= 100000) continue;
            cntR[k+R[j]] += cntR[k];
            cntR[k+R[j]] %= MOD;
        }
    }

    int64_t ans = 0;
    for(int k=1; k<100000; k++) {
        ans += cntR[k] * (cntV[min(B*k,99999L)] - cntV[min(A*k-1,99999L)]);
        ans %= MOD;
    }

    if(ans < 0) ans += MOD;
    cout << ans << endl;
    return 0;
}
0