結果

問題 No.1043 直列大学
ユーザー hasegawa1hasegawa1
提出日時 2020-05-01 22:03:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,102 bytes
コンパイル時間 872 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-25 10:11:20
合計ジャッジ時間 5,455 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 2
other AC * 5 RE * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

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[B*k] - cntV[A*k-1]);
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}
0