結果

問題 No.1043 直列大学
ユーザー cn_449cn_449
提出日時 2020-05-01 22:27:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 2,225 bytes
コンパイル時間 1,213 ms
コンパイル使用メモリ 119,312 KB
実行使用メモリ 162,080 KB
最終ジャッジ日時 2023-08-24 05:49:06
合計ジャッジ時間 6,545 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
161,780 KB
testcase_01 AC 118 ms
161,888 KB
testcase_02 AC 117 ms
161,888 KB
testcase_03 AC 115 ms
161,896 KB
testcase_04 AC 115 ms
161,772 KB
testcase_05 AC 115 ms
161,812 KB
testcase_06 AC 118 ms
161,912 KB
testcase_07 AC 117 ms
161,884 KB
testcase_08 AC 117 ms
161,964 KB
testcase_09 AC 134 ms
161,892 KB
testcase_10 AC 133 ms
161,812 KB
testcase_11 AC 142 ms
161,776 KB
testcase_12 AC 144 ms
161,856 KB
testcase_13 AC 142 ms
161,784 KB
testcase_14 AC 143 ms
161,888 KB
testcase_15 AC 145 ms
161,756 KB
testcase_16 AC 141 ms
161,908 KB
testcase_17 AC 135 ms
161,888 KB
testcase_18 AC 134 ms
161,904 KB
testcase_19 AC 140 ms
161,772 KB
testcase_20 AC 134 ms
161,920 KB
testcase_21 AC 137 ms
161,820 KB
testcase_22 AC 141 ms
161,996 KB
testcase_23 AC 144 ms
161,752 KB
testcase_24 AC 136 ms
161,748 KB
testcase_25 AC 140 ms
161,752 KB
testcase_26 AC 145 ms
161,772 KB
testcase_27 AC 127 ms
161,808 KB
testcase_28 AC 138 ms
161,912 KB
testcase_29 AC 122 ms
161,752 KB
testcase_30 AC 132 ms
162,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, m;
	cin >> n >> m;
	vector<int> v(n), r(m);
	rep(i, n) cin >> v[i];
	rep(i, m) cin >> r[i];
	ll a, b;
	cin >> a >> b;
	vector<vector<ll>> dpv(101, vector<ll>(100010));
	vector<vector<ll>> dpr(101, vector<ll>(100010));
	dpv[0][0] = dpr[0][0] = 1;
	rep(i, n) {
		rep(j, 100009) {
			dpv[i + 1][j] = dpv[i][j];
			if (j >= v[i]) {
				dpv[i + 1][j] += dpv[i][j - v[i]];
				if (dpv[i + 1][j] >= mod) dpv[i + 1][j] -= mod;
			}
		}
	}
	rep(i, m) {
		rep(j, 100009) {
			dpr[i + 1][j] = dpr[i][j];
			if (j >= r[i]) {
				dpr[i + 1][j] += dpr[i][j - r[i]];
				if (dpr[i + 1][j] >= mod) dpr[i + 1][j] -= mod;
			}
		}
	}
	ll ans = 0;
	vector<ll> vsum(100010);
	rep(i, 100009) {
		vsum[i + 1] = vsum[i] + dpv[n][i + 1];
		if (vsum[i + 1] >= mod) vsum[i + 1] -= mod;
	}
	rep(i, 100010) {
		if (i == 0) continue;
		ll c = vsum[min(100009LL, i*b)] - vsum[min(100009LL, i*a - 1)];
		if (c < 0) c += mod;
		c *= dpr[m][i]; c %= mod;
		ans += c;
		if (ans >= mod) ans -= mod;
	}
	cout << ans << '\n';
}
0