結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,580 KB
testcase_01 AC 3 ms
4,880 KB
testcase_02 AC 4 ms
4,632 KB
testcase_03 AC 3 ms
4,736 KB
testcase_04 AC 3 ms
4,676 KB
testcase_05 AC 3 ms
4,556 KB
testcase_06 AC 3 ms
4,664 KB
testcase_07 AC 4 ms
4,664 KB
testcase_08 AC 3 ms
4,580 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 18 ms
4,744 KB
testcase_15 AC 19 ms
4,552 KB
testcase_16 AC 18 ms
4,560 KB
testcase_17 AC 14 ms
4,576 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 15 ms
4,680 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 11 ms
4,628 KB
testcase_28 WA -
testcase_29 AC 7 ms
4,736 KB
testcase_30 AC 13 ms
4,608 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];
        }
    }
    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];
        }
    }

    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