結果

問題 No.1043 直列大学
ユーザー leaf_1415leaf_1415
提出日時 2020-05-01 21:41:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 1,470 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 74,892 KB
実行使用メモリ 161,368 KB
最終ジャッジ日時 2023-08-24 05:40:21
合計ジャッジ時間 4,857 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
10,816 KB
testcase_01 AC 6 ms
6,196 KB
testcase_02 AC 11 ms
14,872 KB
testcase_03 AC 5 ms
6,332 KB
testcase_04 AC 5 ms
6,220 KB
testcase_05 AC 5 ms
6,328 KB
testcase_06 AC 5 ms
6,256 KB
testcase_07 AC 8 ms
10,860 KB
testcase_08 AC 8 ms
10,840 KB
testcase_09 AC 61 ms
84,532 KB
testcase_10 AC 72 ms
98,860 KB
testcase_11 AC 110 ms
148,620 KB
testcase_12 AC 116 ms
161,368 KB
testcase_13 AC 97 ms
134,436 KB
testcase_14 AC 105 ms
143,464 KB
testcase_15 AC 115 ms
156,236 KB
testcase_16 AC 104 ms
138,924 KB
testcase_17 AC 76 ms
103,156 KB
testcase_18 AC 76 ms
104,156 KB
testcase_19 AC 95 ms
132,000 KB
testcase_20 AC 72 ms
100,096 KB
testcase_21 AC 89 ms
121,348 KB
testcase_22 AC 91 ms
127,204 KB
testcase_23 AC 117 ms
160,864 KB
testcase_24 AC 81 ms
112,748 KB
testcase_25 AC 97 ms
134,528 KB
testcase_26 AC 103 ms
142,208 KB
testcase_27 AC 51 ms
70,436 KB
testcase_28 AC 95 ms
131,048 KB
testcase_29 AC 33 ms
45,592 KB
testcase_30 AC 72 ms
99,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n, m;
llint v[105], r[105];
llint a, b;
llint dp[105][100005], dp2[105][100005];

void calc(llint a[], llint n, llint dp[105][100005])
{
	dp[0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 100005; j++){
			(dp[i+1][j] += dp[i][j]) %= mod;
			if(j+a[i+1] < 100005) (dp[i+1][j+a[i+1]] += dp[i][j]) %= mod;
		}
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> v[i];
	for(int i = 1; i <= m; i++) cin >> r[i];
	cin >> a >> b;
	
	calc(v, n, dp);
	calc(r, m, dp2);
	
	for(int i = 1; i < 100005; i++) dp[n][i] += dp[n][i-1], dp[n][i] %= mod;
	
	llint ans = 0;
	for(int i = 1; i < 100005; i++){
		ans += dp2[m][i] * dp[n][min(100004LL, b*i)] % mod, ans %= mod;
		ans += mod - dp2[m][i] * dp[n][min(100004LL, a*i-1)] % mod, ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}
0