結果

問題 No.1043 直列大学
ユーザー recososorecososo
提出日時 2020-05-01 22:01:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,626 bytes
コンパイル時間 1,543 ms
コンパイル使用メモリ 169,096 KB
実行使用メモリ 5,772 KB
最終ジャッジ日時 2023-08-26 12:14:58
合計ジャッジ時間 5,363 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,336 KB
testcase_01 AC 5 ms
5,464 KB
testcase_02 AC 7 ms
5,380 KB
testcase_03 AC 5 ms
5,344 KB
testcase_04 AC 5 ms
5,336 KB
testcase_05 AC 6 ms
5,428 KB
testcase_06 AC 6 ms
5,340 KB
testcase_07 AC 6 ms
5,372 KB
testcase_08 AC 6 ms
5,344 KB
testcase_09 AC 26 ms
5,352 KB
testcase_10 AC 31 ms
5,332 KB
testcase_11 AC 46 ms
5,340 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 36 ms
5,336 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 46 ms
5,340 KB
testcase_22 AC 46 ms
5,392 KB
testcase_23 AC 58 ms
5,336 KB
testcase_24 AC 39 ms
5,380 KB
testcase_25 AC 48 ms
5,448 KB
testcase_26 AC 51 ms
5,316 KB
testcase_27 AC 28 ms
5,408 KB
testcase_28 AC 44 ms
5,348 KB
testcase_29 AC 16 ms
5,344 KB
testcase_30 AC 38 ms
5,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    vector<int> v(n),r(m);
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    for(int i=0;i<m;i++){
        cin >> r[i];
    }
    int a,b;cin >> a >> b;
    const int cmx=100000;
    vector<ll> dv(cmx+1),dr(cmx+1);
    dv[0]=1,dr[0]=1;
    for(int i=0;i<n;i++){
        vector<ll> tv(cmx+1);
        for(int j=0;j<=cmx;j++){
            if(dv[j]==0){
                continue;
            }
            (tv[j]+=dv[j])%=mod;
            if(j+v[i]<=cmx){
                (tv[j+v[i]]+=dv[j])%=mod;
            }
        }
        for(int j=0;j<=cmx;j++){
            dv[j]=tv[j];
        }
    }
    for(int i=0;i<m;i++){
        vector<ll> tr(cmx+1);
        for(int j=0;j<=cmx;j++){
            if(dr[j]==0){
                continue;
            }
            (tr[j]+=dr[j])%=mod;
            if(j+v[i]<=cmx){
                (tr[j+r[i]]+=dr[j])%=mod;
            }
        }
        for(int j=0;j<=cmx;j++){
            dr[j]=tr[j];
        }
    }
    vector<ll> sv(cmx+1);
    for(int i=1;i<=cmx;i++){
        (sv[i]=sv[i-1]+dv[i])%=mod;
    }
    ll ans=0;
    for(int i=1;i<=cmx;i++){
        (ans+=(sv[min(cmx,i*b)]-sv[min(cmx,i*a-1)]+mod)%mod*dr[i]%mod)%=mod;
    }
    cout << ans << endl;
}
0