結果

問題 No.1043 直列大学
ユーザー HaaHaa
提出日時 2020-05-01 22:10:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 920 bytes
コンパイル時間 1,542 ms
コンパイル使用メモリ 167,856 KB
実行使用メモリ 4,864 KB
最終ジャッジ日時 2023-08-24 05:45:44
合計ジャッジ時間 3,334 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,756 KB
testcase_01 AC 4 ms
4,548 KB
testcase_02 AC 5 ms
4,704 KB
testcase_03 AC 4 ms
4,756 KB
testcase_04 AC 4 ms
4,700 KB
testcase_05 AC 4 ms
4,728 KB
testcase_06 AC 4 ms
4,564 KB
testcase_07 AC 5 ms
4,700 KB
testcase_08 AC 5 ms
4,604 KB
testcase_09 AC 22 ms
4,556 KB
testcase_10 AC 26 ms
4,676 KB
testcase_11 AC 37 ms
4,620 KB
testcase_12 AC 40 ms
4,612 KB
testcase_13 AC 33 ms
4,760 KB
testcase_14 AC 36 ms
4,864 KB
testcase_15 AC 39 ms
4,716 KB
testcase_16 AC 35 ms
4,568 KB
testcase_17 AC 27 ms
4,600 KB
testcase_18 AC 27 ms
4,864 KB
testcase_19 AC 33 ms
4,600 KB
testcase_20 AC 26 ms
4,760 KB
testcase_21 AC 31 ms
4,736 KB
testcase_22 AC 32 ms
4,552 KB
testcase_23 AC 40 ms
4,564 KB
testcase_24 AC 29 ms
4,604 KB
testcase_25 AC 33 ms
4,564 KB
testcase_26 AC 36 ms
4,676 KB
testcase_27 AC 19 ms
4,548 KB
testcase_28 AC 33 ms
4,552 KB
testcase_29 AC 13 ms
4,680 KB
testcase_30 AC 25 ms
4,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

const ll MAX=100000;

int main() {
	int n, m; cin >> n >> m;
	VI v(n), r(m);
	REP(i,n) cin >> v[i];
	REP(i,m) cin >> r[i];
	ll a, b; cin >> a >> b;
	VI pv(MAX+1,0), pr(MAX+1,0); 
	pv[0]=1; pr[0]=1;
	REP(i,n)for(int j=MAX;j>=v[i];j--){
			pv[j]+=pv[j-v[i]];
			pv[j]%=MOD;
	}
	REP(i,m)for(int j=MAX;j>=r[i];j--){
			pr[j]+=pr[j-r[i]];
			pr[j]%=MOD;
	}
	REP(i,MAX){
		pv[i+1]+=pv[i];
		pv[i+1]%=MOD;
	}
	ll ans=0;
	for(int i=1;i<=MAX;i++){
		if(pr[i]==0) continue;
		ll l=a*i, rr=min(MAX,b*i);
		if(l>MAX) break;
		ans+=pr[i]*((pv[rr]-pv[l-1])+2*MOD)%MOD;
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}
0