結果
問題 | No.1238 選抜クラス |
ユーザー | kya_ski |
提出日時 | 2020-09-25 21:49:42 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 295 ms / 2,000 ms |
コード長 | 3,214 bytes |
コンパイル時間 | 865 ms |
コンパイル使用メモリ | 79,228 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-06-28 06:23:25 |
合計ジャッジ時間 | 6,738 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 3 ms
5,376 KB |
testcase_02 | AC | 6 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 4 ms
5,376 KB |
testcase_08 | AC | 5 ms
5,376 KB |
testcase_09 | AC | 9 ms
5,632 KB |
testcase_10 | AC | 4 ms
5,376 KB |
testcase_11 | AC | 9 ms
5,632 KB |
testcase_12 | AC | 6 ms
5,376 KB |
testcase_13 | AC | 6 ms
5,376 KB |
testcase_14 | AC | 6 ms
5,376 KB |
testcase_15 | AC | 9 ms
5,760 KB |
testcase_16 | AC | 8 ms
5,504 KB |
testcase_17 | AC | 290 ms
19,200 KB |
testcase_18 | AC | 274 ms
18,560 KB |
testcase_19 | AC | 283 ms
18,816 KB |
testcase_20 | AC | 264 ms
18,432 KB |
testcase_21 | AC | 247 ms
17,792 KB |
testcase_22 | AC | 295 ms
19,200 KB |
testcase_23 | AC | 286 ms
19,072 KB |
testcase_24 | AC | 288 ms
19,200 KB |
testcase_25 | AC | 284 ms
19,072 KB |
testcase_26 | AC | 284 ms
19,072 KB |
testcase_27 | AC | 285 ms
19,072 KB |
testcase_28 | AC | 282 ms
19,072 KB |
testcase_29 | AC | 272 ms
18,944 KB |
testcase_30 | AC | 29 ms
8,320 KB |
testcase_31 | AC | 88 ms
12,032 KB |
testcase_32 | AC | 167 ms
15,488 KB |
testcase_33 | AC | 3 ms
5,376 KB |
testcase_34 | AC | 207 ms
16,768 KB |
testcase_35 | AC | 44 ms
9,472 KB |
testcase_36 | AC | 12 ms
6,272 KB |
testcase_37 | AC | 33 ms
8,576 KB |
testcase_38 | AC | 260 ms
18,432 KB |
ソースコード
#include <iostream> #include <cstdint> #include <cassert> template<std::int_fast32_t Modulus> struct modint { using value_type = std::int_fast32_t; static constexpr std::int_fast32_t mod = Modulus; static_assert(mod > 1, "Modulus must be greater than 1"); private : value_type x; template<class Tp> static constexpr value_type normalize (Tp value) noexcept { if (value < 0) { value = (-value) % mod; return (value ? value : mod - value); } return (value % mod); } public : explicit constexpr modint () noexcept : x(0) { } template<class Tp> constexpr modint (Tp value) noexcept : x(normalize(value)) { } constexpr modint operator+ () const noexcept { return modint(*this); } constexpr modint operator- () noexcept { if (x != 0) x = mod - x; return modint(*this); } constexpr modint &operator+= (const modint &p) noexcept { if ((x += p.x) >= mod) x -= mod; return (*this); } constexpr modint &operator-= (const modint &p) noexcept { if ((x += mod - p.x) >= mod) x -= mod; return (*this); } constexpr modint &operator*= (const modint &p) noexcept { x = (int)(1LL * x * p.x % mod); return (*this); } constexpr modint &operator/= (const modint &p) noexcept { return ((*this) *= p.inverse()); } constexpr modint operator+ (const modint &p) const noexcept { return (modint(*this) += p); } constexpr modint operator- (const modint &p) const noexcept { return (modint(*this) -= p); } constexpr modint operator* (const modint &p) const noexcept { return (modint(*this) *= p); } constexpr modint operator/ (const modint &p) const noexcept { return (modint(*this) /= p); } constexpr bool operator== (const modint &p) const noexcept { return (x == p.x); } constexpr bool operator!= (const modint &p) const noexcept { return (x != p.x); } template<class Tp> constexpr modint pow (Tp exp) const noexcept { modint value(1), buff(x); while (exp) { if (exp & 1) value *= buff; buff *= buff; exp >>= 1; } return value; } constexpr modint inverse () const noexcept { return pow(mod - 2); } friend std::ostream &operator<< (std::ostream &os, const modint &p) { return (os << p.x); } friend std::istream &operator>> (std::istream &is, modint &p) { long long v; is >> v; p = modint(v); return (is); } }; #include <iostream> #include <cstddef> #include <vector> using usize = std::size_t; using i32 = std::int_fast32_t; template<class T> using matrix = std::vector<std::vector<T>>; constexpr std::int_fast32_t MOD = 1000000007; constexpr usize MAX = 10010; int main() { usize n, k; std::cin >> n >> k; std::vector<usize> a(n); for (usize i = 0; i < n; i++) { std::cin >> a[i]; } matrix<modint<MOD>> dp(n + 1, std::vector<modint<MOD>>(MAX, 0)); matrix<modint<MOD>> next(n + 1, std::vector<modint<MOD>>(MAX, 0)); dp[0][0] = next[0][0] = 1; for (usize i = 0; i < n; i++) { for (usize j = 0; j < n; j++) { for (usize k = 0; k + a[i] < MAX; k++) { next[j + 1][k + a[i]] += dp[j][k]; } } dp = next; } modint<MOD> ans = 0; for (usize i = 1; i <= n; i++) { for (usize j = i * k; j < MAX; j++) { ans += dp[i][j]; } } std::cout << ans << '\n'; return 0; }