結果

問題 No.1043 直列大学
ユーザー KY2001KY2001
提出日時 2020-05-01 22:49:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,903 bytes
コンパイル時間 2,143 ms
コンパイル使用メモリ 202,200 KB
実行使用メモリ 5,164 KB
最終ジャッジ日時 2023-08-26 15:31:44
合計ジャッジ時間 4,261 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,756 KB
testcase_01 AC 4 ms
4,616 KB
testcase_02 AC 6 ms
4,940 KB
testcase_03 AC 5 ms
4,620 KB
testcase_04 AC 4 ms
5,160 KB
testcase_05 AC 4 ms
4,724 KB
testcase_06 AC 4 ms
4,620 KB
testcase_07 AC 5 ms
5,116 KB
testcase_08 AC 5 ms
4,612 KB
testcase_09 AC 23 ms
5,164 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 41 ms
4,992 KB
testcase_13 WA -
testcase_14 AC 36 ms
4,592 KB
testcase_15 AC 39 ms
4,564 KB
testcase_16 AC 35 ms
4,988 KB
testcase_17 AC 26 ms
4,608 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 40 ms
4,560 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] = (container[i + 1] + container[i]) % MOD;
}

signed main() {
  int N, M;
  cin >> N >> M;
  vector<int> V(N);
  vector<int> R(M);
  rep(i, N) cin >> V[i];
  rep(i, M) cin >> R[i];
  int A, B;
  cin >> A >> B;
  vector<int> resist(100000 + 10000, 0);
  vector<int> electricity(100000 + 10000, 0);
  resist[0]      = 1;
  electricity[0] = 1;
  rep(i, N) {
    for (int j = 100000; j >= 0; j--) {
      if (j - R[i] >= 0) resist[j] = (resist[j] + resist[j - R[i]]) % MOD;
    }
  }
  rep(i, M) {
    for (int j = 100000; j >= 0; j--) {
      if (j - V[i] >= 0) electricity[j] = (electricity[j] + electricity[j - V[i]]) % MOD;
    }
  }
  cumulative_sum(electricity);
  int ans = 0;
  rep(i, 100000) {
    if (A * (i + 1) > 100000) break;
    ans = (ans + resist[i + 1] * (electricity[min(B * (i + 1), 100000LL)] - electricity[A * (i + 1) - 1LL])) % MOD;
  }
  cout << ans << endl;
}
0