結果
問題 | No.1043 直列大学 |
ユーザー | shimarut |
提出日時 | 2021-03-26 21:58:32 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,485 bytes |
コンパイル時間 | 3,793 ms |
コンパイル使用メモリ | 186,792 KB |
実行使用メモリ | 82,936 KB |
最終ジャッジ日時 | 2024-05-06 15:28:43 |
合計ジャッジ時間 | 6,064 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
6,108 KB |
testcase_01 | AC | 4 ms
5,376 KB |
testcase_02 | AC | 8 ms
8,564 KB |
testcase_03 | AC | 4 ms
5,376 KB |
testcase_04 | AC | 4 ms
5,376 KB |
testcase_05 | AC | 4 ms
5,464 KB |
testcase_06 | AC | 4 ms
5,376 KB |
testcase_07 | AC | 7 ms
6,892 KB |
testcase_08 | AC | 5 ms
6,764 KB |
testcase_09 | AC | 58 ms
43,488 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 94 ms
67,988 KB |
testcase_29 | AC | 30 ms
23,924 KB |
testcase_30 | AC | 72 ms
51,892 KB |
ソースコード
#pragma region #define _USE_MATH_DEFINES #include <iostream> #include <string> #include <algorithm> #include <cmath> #include <cstdlib> #include <vector> #include <map> #include <queue> #include <stack> #include <set> #include <list> #include <iomanip> #include <cstdint> #include <bitset> #include <sstream> #include <regex> #include <fstream> #include <array> #include <atcoder/all> using namespace atcoder; using mint = modint1000000007; //using mint = modint998244353; //using mint = modint; using namespace std; typedef long long ll; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using pint = pair<int, int>; using pll = pair<ll, ll>; //#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i)) #define rep(i, e) for (int(i) = 0; (i) < (e); ++(i)) #define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i)) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #pragma region UnionFind struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) {} void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; #pragma endregion #pragma region GCD ll gcd(ll a, ll b) { if (b == 0)return a; return gcd(b, a % b); } #pragma endregion #pragma region LCM ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } #pragma endregion #pragma region chmin template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } #pragma endregion #pragma region chmax template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } #pragma endregion #pragma region グリッド内チェック bool out(int x, int y, int h, int w) { if (x < 0 || h <= x || y < 0 || w <= y)return true; else return false; } #pragma endregion #pragma region Dijkstra vl dijkstra(vector<vector<pair<int, ll>>> v, int s) { ll INF = 1e18; int MAX = 1e6; vl res(MAX, INF); priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q; q.push({ 0,s }); while (!q.empty()) { int now; ll d; tie(d, now) = q.top(); q.pop(); if (!chmin(res[now], d))continue; for (auto p : v[now]) { int next; ll c; tie(next, c) = p; if (res[next] <= res[now] + c)continue; q.push({ res[now] + c,next }); } } return res; } #pragma endregion #pragma endregion 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; vector<vector<mint>> dp1(n + 1, vector<mint>(100100)), dp2(m + 1, vector<mint>(100100)); dp1[0][0] = dp2[0][0] = 1; int MAX = 1e5; rep(i, n)rep(j, MAX + 1) { dp1[i + 1][j] += dp1[i][j]; if (j + v[i] > MAX)continue; dp1[i + 1][j + v[i]] += dp1[i][j]; } rep(i, m)rep(j, MAX + 1) { dp2[i + 1][j] += dp2[i][j]; if (j + r[i] > MAX)continue; dp2[i + 1][j + r[i]] += dp2[i][j]; } vector<mint> s(MAX + 11); rep(i, MAX + 10)s[i + 1] = s[i] + dp1[n][i]; mint res = 0; for (int i = 1; i <= MAX; ++i) { if (dp2[m][i] == 0)continue; ll l = min(MAX + 10LL, a * i); ll r = min(MAX + 10LL, b * i); res += (s[r + 1] - s[l])*dp2[m][i]; } cout << res.val() << endl; }