結果

問題 No.1043 直列大学
ユーザー kk
提出日時 2020-09-03 19:45:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,150 bytes
コンパイル時間 2,244 ms
コンパイル使用メモリ 201,676 KB
実行使用メモリ 4,780 KB
最終ジャッジ日時 2023-08-24 12:53:31
合計ジャッジ時間 4,038 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,564 KB
testcase_01 AC 5 ms
4,688 KB
testcase_02 AC 7 ms
4,556 KB
testcase_03 AC 5 ms
4,676 KB
testcase_04 AC 5 ms
4,676 KB
testcase_05 AC 5 ms
4,608 KB
testcase_06 AC 5 ms
4,676 KB
testcase_07 AC 6 ms
4,608 KB
testcase_08 AC 5 ms
4,700 KB
testcase_09 AC 23 ms
4,608 KB
testcase_10 AC 27 ms
4,608 KB
testcase_11 AC 38 ms
4,780 KB
testcase_12 AC 41 ms
4,568 KB
testcase_13 AC 35 ms
4,612 KB
testcase_14 AC 37 ms
4,556 KB
testcase_15 AC 40 ms
4,668 KB
testcase_16 AC 36 ms
4,680 KB
testcase_17 AC 28 ms
4,556 KB
testcase_18 AC 27 ms
4,572 KB
testcase_19 AC 34 ms
4,680 KB
testcase_20 AC 27 ms
4,616 KB
testcase_21 AC 32 ms
4,672 KB
testcase_22 AC 33 ms
4,676 KB
testcase_23 AC 41 ms
4,672 KB
testcase_24 AC 30 ms
4,556 KB
testcase_25 AC 34 ms
4,620 KB
testcase_26 AC 37 ms
4,572 KB
testcase_27 AC 20 ms
4,676 KB
testcase_28 AC 34 ms
4,596 KB
testcase_29 AC 14 ms
4,676 KB
testcase_30 AC 27 ms
4,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);
const long long MOD = 1000000007;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  cin >> n >> m;
  vector<int> v(n), r(m);

  REP (i, n) cin >> v[i];
  REP (i, m) cin >> r[i];

  int a, b;
  cin >> a >> b;
  
  // v pattern
  vector<long long> pv(100000 + 1);
  pv[0] = 1;
  REP (i, n) for (int j = pv.size() - 1; j >= 0; j--) if (j >= v[i]) (pv[j] += pv[j-v[i]]) %= MOD;
  
  // r pattern
  vector<long long> pr(100000 + 1);
  pr[0] = 1;
  REP (i, m) for (int j = pr.size() - 1; j >= 0; j--) if (j >= r[i]) (pr[j] += pr[j-r[i]]) %= MOD;
  for (int i = 1; i < pr.size(); i++) (pr[i] += pr[i-1]) %= MOD;
  
  long long ret = 0;
  for (int i = 1; i < pv.size(); i++) {
    long long x = pv[i];
    int rmin = (i + b - 1) / b;
    int rmax = i / a;
    long long y = pr[rmax] - pr[rmin-1];
    y %= MOD;
    if (y < 0) y += MOD;
    (ret += x * y % MOD) %= MOD;
  }

  cout << ret << endl;
  
  return 0;
}
0