結果

問題 No.1043 直列大学
ユーザー nanophoto12nanophoto12
提出日時 2020-05-06 11:11:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,403 bytes
コンパイル時間 2,284 ms
コンパイル使用メモリ 200,648 KB
実行使用メモリ 5,544 KB
最終ジャッジ日時 2023-09-10 20:03:09
合計ジャッジ時間 4,155 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,492 KB
testcase_01 AC 4 ms
5,420 KB
testcase_02 AC 5 ms
5,464 KB
testcase_03 AC 5 ms
5,368 KB
testcase_04 AC 4 ms
5,460 KB
testcase_05 AC 4 ms
5,460 KB
testcase_06 AC 4 ms
5,368 KB
testcase_07 AC 5 ms
5,308 KB
testcase_08 AC 5 ms
5,364 KB
testcase_09 AC 15 ms
5,420 KB
testcase_10 AC 17 ms
5,360 KB
testcase_11 WA -
testcase_12 AC 33 ms
5,440 KB
testcase_13 WA -
testcase_14 AC 30 ms
5,412 KB
testcase_15 AC 33 ms
5,424 KB
testcase_16 AC 30 ms
5,412 KB
testcase_17 AC 23 ms
5,368 KB
testcase_18 AC 22 ms
5,368 KB
testcase_19 AC 29 ms
5,308 KB
testcase_20 AC 21 ms
5,444 KB
testcase_21 AC 27 ms
5,464 KB
testcase_22 AC 28 ms
5,480 KB
testcase_23 AC 34 ms
5,316 KB
testcase_24 AC 24 ms
5,480 KB
testcase_25 AC 29 ms
5,488 KB
testcase_26 AC 31 ms
5,540 KB
testcase_27 AC 15 ms
5,368 KB
testcase_28 AC 24 ms
5,424 KB
testcase_29 AC 9 ms
5,312 KB
testcase_30 AC 24 ms
5,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

const ll mod = 1e9 + 7;

const ll INF = 1e15;

int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll> vs(n);
	vector<ll> rs(m);
	rep(i, n) cin >> vs[i];
	rep(i, m) cin >> rs[i];
	ll a, b;
	cin >> a >> b;
	const ll maxN = 100 * 1000 + 1;
	vector<ll> vss(maxN, 0);
	vss[0] = 1;
	rep(i, n) {
		for (int j = maxN - 1 - vs[i]; j >= 0; j--) {
			if (vss[j]) {
				vss[j + vs[i]] += vss[j];
				vss[j + vs[i]] %= mod;
			}
		}
	}
	vector<ll> rss(maxN, 0);
	rss[0] = 1;
	rep(i, m) {
		for (int j = maxN - 1 - rs[i]; j >= 0; j--) {
			if (rss[j]) {
				rss[j + rs[i]] += rss[j];
				rss[j + rs[i]] %= mod;
			}
		}
	}
	vector<ll> vssSum(maxN+1, 0);
	rep(i, maxN) {
		vssSum[i + 1] = vss[i] + vssSum[i];
		vssSum[i + 1] %= mod;
	}
	ll sum = 0;
	for (int i = 1; i < maxN; i++) {
		ll count = rss[i];
		if (count == 0) continue;
		ll ra = i * a;
		ll rb = i * b;
		ll c = vssSum[min(maxN, rb+1)] - vssSum[min(maxN,ra)];
		c %= mod;
		c *= count;
		c %= mod;
		sum += c;
		sum %= mod;
	}
	cout << sum << endl;
	return 0;
}
0