結果

問題 No.1043 直列大学
ユーザー recososorecososo
提出日時 2020-05-01 22:04:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,623 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 170,072 KB
実行使用メモリ 5,600 KB
最終ジャッジ日時 2023-08-24 05:43:30
合計ジャッジ時間 3,849 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,388 KB
testcase_01 AC 5 ms
5,340 KB
testcase_02 AC 7 ms
5,364 KB
testcase_03 AC 5 ms
5,340 KB
testcase_04 AC 5 ms
5,472 KB
testcase_05 AC 5 ms
5,492 KB
testcase_06 AC 5 ms
5,412 KB
testcase_07 AC 6 ms
5,444 KB
testcase_08 AC 6 ms
5,388 KB
testcase_09 AC 24 ms
5,412 KB
testcase_10 AC 28 ms
5,332 KB
testcase_11 AC 40 ms
5,396 KB
testcase_12 AC 55 ms
5,440 KB
testcase_13 AC 45 ms
5,600 KB
testcase_14 AC 49 ms
5,368 KB
testcase_15 AC 54 ms
5,476 KB
testcase_16 AC 47 ms
5,388 KB
testcase_17 AC 34 ms
5,472 KB
testcase_18 AC 33 ms
5,464 KB
testcase_19 AC 44 ms
5,472 KB
testcase_20 AC 33 ms
5,380 KB
testcase_21 AC 41 ms
5,484 KB
testcase_22 AC 43 ms
5,456 KB
testcase_23 AC 55 ms
5,460 KB
testcase_24 AC 36 ms
5,340 KB
testcase_25 AC 45 ms
5,408 KB
testcase_26 AC 47 ms
5,344 KB
testcase_27 AC 25 ms
5,464 KB
testcase_28 AC 41 ms
5,464 KB
testcase_29 AC 15 ms
5,440 KB
testcase_30 AC 36 ms
5,344 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];
    }
    ll a,b;cin >> a >> b;
    const ll 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(ll 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