結果

問題 No.1043 直列大学
ユーザー Arumakan_ei1727Arumakan_ei1727
提出日時 2020-05-02 00:31:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,933 bytes
コンパイル時間 2,023 ms
コンパイル使用メモリ 201,276 KB
実行使用メモリ 26,704 KB
最終ジャッジ日時 2023-08-26 18:15:25
合計ジャッジ時間 9,505 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
26,420 KB
testcase_01 AC 18 ms
26,428 KB
testcase_02 AC 30 ms
26,424 KB
testcase_03 AC 17 ms
26,388 KB
testcase_04 AC 15 ms
26,332 KB
testcase_05 AC 15 ms
26,392 KB
testcase_06 AC 16 ms
26,416 KB
testcase_07 AC 23 ms
26,376 KB
testcase_08 AC 22 ms
26,520 KB
testcase_09 AC 176 ms
26,508 KB
testcase_10 AC 209 ms
26,372 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 284 ms
26,428 KB
testcase_14 AC 298 ms
26,304 KB
testcase_15 AC 328 ms
26,484 KB
testcase_16 AC 292 ms
26,304 KB
testcase_17 AC 217 ms
26,392 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 256 ms
26,304 KB
testcase_22 AC 267 ms
26,520 KB
testcase_23 AC 337 ms
26,360 KB
testcase_24 AC 240 ms
26,464 KB
testcase_25 AC 280 ms
26,448 KB
testcase_26 AC 301 ms
26,436 KB
testcase_27 AC 150 ms
26,420 KB
testcase_28 AC 276 ms
26,372 KB
testcase_29 AC 94 ms
26,360 KB
testcase_30 AC 212 ms
26,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

constexpr int MOD = int(1e9) + 7;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, N, M);
    vector<i64> V(N), R(M);
    read(V, R);
    var(i64, A, B);

    constexpr int MX = 1e6 + 1000;

    vector<i64> dpV(MX + 2000);
    dpV[0] = 1;
    for (const i64 v : V) {
        repr(i, MX, 0)(dpV[i + v] += dpV[i]) %= MOD;
    }

    vector<i64> dpR(MX + 2000);
    dpR[0] = 1;
    for (const i64 r : R) {
        repr(i, MX, 0)(dpR[i + r] += dpR[i]) %= MOD;
    }

    vector<i64> cumV(MX + 1);
    rep(i, 0, MX) { cumV[i + 1] = (cumV[i] + dpV[i]) % MOD; }

    i64 ans = 0;
    repc(sumR, 1, 1e6) {
        if (dpR[sumR] == 0) continue;
        if (A * sumR >= MX || B * sumR >= MX) continue;
        const i64 vv = (cumV[B * sumR + 1] - cumV[A * sumR] + MOD) % MOD;
        ans += dpR[sumR] * vv % MOD;
        ans %= MOD;
    }

    print(ans);

    return 0;
}
0