結果

問題 No.1043 直列大学
ユーザー auauaauaua
提出日時 2020-05-01 22:46:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 1,531 bytes
コンパイル時間 1,607 ms
コンパイル使用メモリ 171,188 KB
実行使用メモリ 161,784 KB
最終ジャッジ日時 2023-08-24 05:50:57
合計ジャッジ時間 5,398 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
8,332 KB
testcase_01 AC 6 ms
6,816 KB
testcase_02 AC 13 ms
13,112 KB
testcase_03 AC 7 ms
7,128 KB
testcase_04 AC 7 ms
6,812 KB
testcase_05 AC 7 ms
6,764 KB
testcase_06 AC 7 ms
6,952 KB
testcase_07 AC 9 ms
10,056 KB
testcase_08 AC 9 ms
10,112 KB
testcase_09 AC 75 ms
83,620 KB
testcase_10 AC 89 ms
99,476 KB
testcase_11 AC 131 ms
148,836 KB
testcase_12 AC 153 ms
161,784 KB
testcase_13 AC 128 ms
135,352 KB
testcase_14 AC 136 ms
143,040 KB
testcase_15 AC 148 ms
156,532 KB
testcase_16 AC 135 ms
139,996 KB
testcase_17 AC 96 ms
103,420 KB
testcase_18 AC 96 ms
103,056 KB
testcase_19 AC 124 ms
132,240 KB
testcase_20 AC 94 ms
101,080 KB
testcase_21 AC 116 ms
121,968 KB
testcase_22 AC 120 ms
127,532 KB
testcase_23 AC 150 ms
160,208 KB
testcase_24 AC 105 ms
113,396 KB
testcase_25 AC 124 ms
133,792 KB
testcase_26 AC 132 ms
143,256 KB
testcase_27 AC 66 ms
71,132 KB
testcase_28 AC 120 ms
132,180 KB
testcase_29 AC 40 ms
44,564 KB
testcase_30 AC 97 ms
100,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n,m;cin>>n>>m;
    vector<ll>v(n);
    vector<ll>r(m);
    rep(i,n)cin>>v[i];
    rep(i,m)cin>>r[i];
    ll a,b;cin>>a>>b;
    vector<vector<ll> >dp(n+1,vector<ll>(100010));
    vector<vector<ll> >dp2(m+1,vector<ll>(100010));
    dp[0][0]=1;
    rep(i,n){
        rep(j,100010){
            if(dp[i][j]==0)continue;
            dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
            dp[i+1][j+v[i]]=(dp[i+1][j+v[i]]+dp[i][j])%mod;
        }
    }
    dp2[0][0]=1;
    rep(i,m){
        rep(j,100010){
            if(dp2[i][j]==0)continue;{
                dp2[i+1][j]=(dp2[i+1][j]+dp2[i][j])%mod;
                dp2[i+1][j+r[i]]=(dp2[i+1][j+r[i]]+dp2[i][j])%mod;
            }
        }
    }
    REP(i,1,100001){
        dp[n][i]=(dp[n][i]+dp[n][i-1])%mod;
    }
    ll ans=0;
    REP(i,1,100001){
        ll c=dp2[m][i];
        ll d;
        if(i*a>100000)d=0;
        else{
            if(i*b>100000)d=(dp[n][100000]-dp[n][a*i-1])%mod;
            else d=(dp[n][b*i]-dp[n][a*i-1])%mod;
        }
        ans=(ans+c*d%mod)%mod;
    }
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
}
0