結果

問題 No.1238 選抜クラス
ユーザー Takoyaki65Takoyaki65
提出日時 2020-10-09 16:17:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 3,535 bytes
コンパイル時間 879 ms
コンパイル使用メモリ 99,288 KB
実行使用メモリ 11,836 KB
最終ジャッジ日時 2023-09-27 12:42:47
合計ジャッジ時間 5,059 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 5 ms
4,408 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 6 ms
4,384 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 149 ms
11,700 KB
testcase_18 AC 138 ms
11,500 KB
testcase_19 AC 144 ms
11,836 KB
testcase_20 AC 134 ms
11,684 KB
testcase_21 AC 126 ms
11,212 KB
testcase_22 AC 150 ms
11,804 KB
testcase_23 AC 151 ms
11,672 KB
testcase_24 AC 145 ms
11,800 KB
testcase_25 AC 146 ms
11,672 KB
testcase_26 AC 151 ms
11,640 KB
testcase_27 AC 148 ms
11,632 KB
testcase_28 AC 150 ms
11,720 KB
testcase_29 AC 145 ms
11,460 KB
testcase_30 AC 17 ms
5,560 KB
testcase_31 AC 47 ms
7,720 KB
testcase_32 AC 88 ms
9,876 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 110 ms
10,372 KB
testcase_35 AC 24 ms
6,664 KB
testcase_36 AC 7 ms
4,680 KB
testcase_37 AC 17 ms
5,872 KB
testcase_38 AC 134 ms
11,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;

template <class T>
inline int sz(T& x) {
    return x.size();
}

template <class T>
inline bool setmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool setmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

template <typename T, T MOD = 1000000007>
struct Mint {
    static constexpr T mod = MOD;
    T v;
    Mint() : v(0) {}
    Mint(signed v) : v(v) {}
    Mint(long long t) {
        v = t % MOD;
        if (v < 0) v += MOD;
    }

    Mint pow(long long k) {
        Mint res(1), tmp(v);
        while (k) {
            if (k & 1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }

    static Mint add_identity() { return Mint(0); }
    static Mint mul_identity() { return Mint(1); }

    Mint inv() { return pow(MOD - 2); }

    Mint& operator+=(Mint a) {
        v += a.v;
        if (v >= MOD) v -= MOD;
        return *this;
    }
    Mint& operator-=(Mint a) {
        v += MOD - a.v;
        if (v >= MOD) v -= MOD;
        return *this;
    }
    Mint& operator*=(Mint a) {
        v = 1LL * v * a.v % MOD;
        return *this;
    }
    Mint& operator/=(Mint a) { return (*this) *= a.inv(); }

    Mint operator+(Mint a) const { return Mint(v) += a; }
    Mint operator-(Mint a) const { return Mint(v) -= a; }
    Mint operator*(Mint a) const { return Mint(v) *= a; }
    Mint operator/(Mint a) const { return Mint(v) /= a; }

    Mint operator-() const { return v ? Mint(MOD - v) : Mint(v); }

    bool operator==(const Mint a) const { return v == a.v; }
    bool operator!=(const Mint a) const { return v != a.v; }
    bool operator<(const Mint a) const { return v < a.v; }

    static Mint comb(long long n, int k) {
        Mint num(1), dom(1);
        for (int i = 0; i < k; i++) {
            num *= Mint(n - i);
            dom *= Mint(i + 1);
        }
        return num / dom;
    }
};
template <typename T, T MOD>
constexpr T Mint<T, MOD>::mod;
template <typename T, T MOD>
ostream& operator<<(ostream& os, Mint<T, MOD> m) {
    os << m.v;
    return os;
}
template <typename T, T MOD>
istream& operator>>(istream& os, Mint<T, MOD>& m) {
    os >> m.v;
    return os;
}

using mint = Mint<long long>;
const int MAX_AK = 11000;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    repeat(i, N) cin >> A[i];
    auto dp = vectors(mint(), N + 1, MAX_AK);
    dp[0][0] = 1;
    for (int ai : A) {
        for (int i = N - 1; i >= 0; --i) {
            repeat(j, MAX_AK) {
                if (j - ai >= 0) {
                    dp[i + 1][j] += dp[i][j - ai];
                }
            }
        }
    }
    mint res = 0;
    repeat_from(i, 1, N + 1) {
        repeat_from(j, i * K, MAX_AK) {
            res += dp[i][j];
        }
    }
    cout << res << endl;
    return 0;
}
0