Submission #13925811
Source Code Expand
Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
int get() const { return (int)x; }
ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
return ModInt(u); }
bool operator==(ModInt that) const { return x == that.x; }
bool operator!=(ModInt that) const { return x != that.x; }
ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
template<typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac;
Comb(){fac.resize(FAC_MAX,1);ifac.resize(FAC_MAX,1);rep(i,1,FAC_MAX)fac[i]=fac[i-1]*i;
ifac[FAC_MAX-1]=T(1)/fac[FAC_MAX-1];rrep(i,FAC_MAX-2,1)ifac[i]=ifac[i+1]*T(i+1);}
T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; }
T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; }
T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0;
return aCb(n + k - 1, k); } // nHk = (n+k-1)Ck : n is separator
T pairCombination(int n) {if(n%2==1)return T(0);return fac[n]*ifac[n/2]/(T(2)^(n/2));}
// combination of paris for n
};
typedef ModInt<998244353> mint;
/*---------------------------------------------------------------------------------------------------
∧_∧
∧_∧ (´<_` ) Welcome to My Coding Space!
( ´_ゝ`) / ⌒i @hamayanhamayan0
/ \ | |
/ / ̄ ̄ ̄ ̄/ |
__(__ニつ/ _/ .| .|____
\/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/
int N, S, A[3010];
Comb<mint, 101010> com;
mint dp[3010][6010];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> N >> S;
rep(i, 0, N) cin >> A[i];
dp[0][0] = mint(2) ^ N;
rep(i, 0, N) rep(tot, 0, S + 1) {
dp[i + 1][tot] += dp[i][tot];
dp[i + 1][tot + A[i]] += dp[i][tot] / 2;
}
cout << dp[N][S] << endl;
}
Submission Info
Judge Result
Set Name |
sample |
All |
Score / Max Score |
0 / 0 |
600 / 600 |
Status |
|
|
Set Name |
Test Cases |
sample |
sample01, sample02, sample03 |
All |
11, 12, 13, 14, 15, 21, 22, 23, 24, 25, 31, 32, 33, 34, 35, 41, 42, 43, 44, 45, 51, 52, 53, 54, sample01, sample02, sample03 |
Case Name |
Status |
Exec Time |
Memory |
11 |
AC |
49 ms |
74468 KB |
12 |
AC |
51 ms |
74580 KB |
13 |
AC |
50 ms |
74528 KB |
14 |
AC |
49 ms |
74556 KB |
15 |
AC |
53 ms |
74448 KB |
21 |
AC |
60 ms |
74500 KB |
22 |
AC |
181 ms |
74528 KB |
23 |
AC |
157 ms |
74552 KB |
24 |
AC |
192 ms |
74452 KB |
25 |
AC |
71 ms |
74472 KB |
31 |
AC |
158 ms |
74448 KB |
32 |
AC |
193 ms |
74560 KB |
33 |
AC |
183 ms |
74452 KB |
34 |
AC |
190 ms |
74516 KB |
35 |
AC |
187 ms |
74504 KB |
41 |
AC |
346 ms |
74560 KB |
42 |
AC |
343 ms |
74560 KB |
43 |
AC |
343 ms |
74568 KB |
44 |
AC |
345 ms |
74532 KB |
45 |
AC |
344 ms |
74600 KB |
51 |
AC |
49 ms |
74564 KB |
52 |
AC |
50 ms |
74468 KB |
53 |
AC |
50 ms |
74472 KB |
54 |
AC |
49 ms |
74408 KB |
sample01 |
AC |
51 ms |
74556 KB |
sample02 |
AC |
49 ms |
74560 KB |
sample03 |
AC |
48 ms |
74448 KB |