結果

問題 No.1043 直列大学
ユーザー Y17Y17
提出日時 2020-05-01 22:24:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 347 ms / 2,000 ms
コード長 1,125 bytes
コンパイル時間 1,566 ms
コンパイル使用メモリ 164,744 KB
実行使用メモリ 26,964 KB
最終ジャッジ日時 2023-08-24 05:48:40
合計ジャッジ時間 8,866 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
26,804 KB
testcase_01 AC 38 ms
26,792 KB
testcase_02 AC 53 ms
26,812 KB
testcase_03 AC 38 ms
26,840 KB
testcase_04 AC 38 ms
26,836 KB
testcase_05 AC 38 ms
26,748 KB
testcase_06 AC 38 ms
26,808 KB
testcase_07 AC 45 ms
26,772 KB
testcase_08 AC 46 ms
26,756 KB
testcase_09 AC 194 ms
26,812 KB
testcase_10 AC 227 ms
26,812 KB
testcase_11 AC 319 ms
26,840 KB
testcase_12 AC 347 ms
26,888 KB
testcase_13 AC 292 ms
26,884 KB
testcase_14 AC 302 ms
26,964 KB
testcase_15 AC 328 ms
26,812 KB
testcase_16 AC 300 ms
26,832 KB
testcase_17 AC 223 ms
26,800 KB
testcase_18 AC 226 ms
26,824 KB
testcase_19 AC 280 ms
26,844 KB
testcase_20 AC 226 ms
26,844 KB
testcase_21 AC 261 ms
26,808 KB
testcase_22 AC 272 ms
26,812 KB
testcase_23 AC 346 ms
26,796 KB
testcase_24 AC 252 ms
26,856 KB
testcase_25 AC 285 ms
26,804 KB
testcase_26 AC 313 ms
26,808 KB
testcase_27 AC 171 ms
26,964 KB
testcase_28 AC 291 ms
26,756 KB
testcase_29 AC 112 ms
26,808 KB
testcase_30 AC 223 ms
26,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long
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; }

int dp1[1000010];
int dp2[1000010];
int rui[1000010];

#define N 1000000ll

#define MOD 1000000007

signed main(){
	int n, m;
	cin >> n >> m;

	int v[1010];
	int r[1010];
	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;

	dp1[0] = 1;
	for(int i = 0;i < n;i++){
		for(int j = N-v[i];j >= 0;j--){
			dp1[j+v[i]] += dp1[j];
			dp1[j+v[i]] %= MOD;
		}
	}
	dp1[0]--;

	dp2[0] = 1;
	for(int i = 0;i < m;i++){
		for(int j = N-r[i];j >= 0;j--){
			dp2[j+r[i]] += dp2[j];
			dp2[j+r[i]] %= MOD;
		}
	}
	dp2[0]--;

	for(int i = 0;i <= N;i++){
		rui[i+1] += rui[i] + dp1[i];
		rui[i+1] %= MOD;
	}

	int ans = 0; 
	for(int i = 0;i <= N;i++){
		int aa = a * i;
		if(aa > N) break;
		int bb = min(N, b*i);
		int tmp = (MOD + rui[bb+1] - rui[aa]) %MOD;
		ans += (tmp * dp2[i]) % MOD;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}
0