Submission #13803925


Source Code Expand

Copy
#include<bits/stdc++.h>

using namespace std;

#define int long long
int mod = 998244353;
int const maxn = 3005;
int a[maxn], dp[maxn][maxn];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, s;
    cin >> n >> s;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= s; ++j) {
            if (s < a[i]) dp[i][j] = dp[i - 1][j] * 2 % mod;
            else {
                dp[i][j] = (dp[i - 1][j] * 2 + dp[i - 1][j - a[i]]) % mod;
            }
        }
    }
    cout << dp[n][s] << '\n';
    return 0;
}

Submission Info

Submission Time
Task F - Knapsack for All Subsets
User traktor74
Language C++ (GCC 9.2.1)
Score 0
Code Size 719 Byte
Status RE
Exec Time 268 ms
Memory 74028 KB

Compile Error

./Main.cpp:10:6: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   10 | main() {
      |      ^

Judge Result

Set Name sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 1
WA × 2
AC × 7
WA × 15
RE × 5
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 WA 12 ms 3712 KB
12 WA 3 ms 4152 KB
13 WA 4 ms 4404 KB
14 AC 2 ms 3812 KB
15 AC 2 ms 3596 KB
21 AC 14 ms 16468 KB
22 RE 268 ms 3352 KB
23 WA 51 ms 35428 KB
24 WA 72 ms 49472 KB
25 RE 106 ms 3352 KB
31 WA 51 ms 40968 KB
32 WA 66 ms 49896 KB
33 WA 65 ms 47428 KB
34 WA 64 ms 48620 KB
35 AC 64 ms 48608 KB
41 WA 118 ms 74004 KB
42 WA 115 ms 74028 KB
43 WA 114 ms 74004 KB
44 RE 107 ms 3372 KB
45 WA 114 ms 73948 KB
51 RE 109 ms 3212 KB
52 RE 108 ms 3348 KB
53 AC 13 ms 15520 KB
54 AC 13 ms 15540 KB
sample01 WA 3 ms 3624 KB
sample02 AC 2 ms 3684 KB
sample03 WA 2 ms 3628 KB