Submission #13816829
Source Code Expand
Copy
#include<bits/stdc++.h> using namespace std; using UL = unsigned int; using ULL = unsigned long long; using LL = long long; #define rep(i, n) for(UL i = 0; i < (n); i++) struct Problem { public: UL N, S; UL A[3000]; static const ULL M = 1000000007; ULL dp[3001][6001] = {}; static const ULL i2 = 500000004; void Solve() { scanf("%u%u", &N, &S); rep(i, N) scanf("%u", A + i); dp[0][0] = 1; rep(i, N) { rep(j, S + 1) dp[i + 1][j] = dp[i][j]; for (UL j = A[i]; j <= S; j++) { dp[i + 1][j] += dp[i][j - A[i]] * i2; dp[i + 1][j] %= M; } } ULL mul = 1; rep(i, N) mul = mul * 2 % M; ULL ans = dp[N][S] * mul % M; cout << ans << endl; } }; int main() { unique_ptr<Problem> p(new Problem()); p->Solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Knapsack for All Subsets |
User | Nachia |
Language | C++ (GCC 9.2.1) |
Score | 0 |
Code Size | 793 Byte |
Status | WA |
Exec Time | 130 ms |
Memory | 143776 KB |
Compile Error
./Main.cpp: In member function ‘void Problem::Solve()’: ./Main.cpp:17:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] 17 | scanf("%u%u", &N, &S); | ~~~~~^~~~~~~~~~~~~~~~ ./Main.cpp:18:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] 18 | rep(i, N) scanf("%u", A + i); | ~~~~~^~~~~~~~~~~~~
Judge Result
Set Name | sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 108 ms | 143776 KB |
12 | WA | 103 ms | 143708 KB |
13 | WA | 103 ms | 143676 KB |
14 | AC | 106 ms | 143644 KB |
15 | AC | 104 ms | 143692 KB |
21 | WA | 104 ms | 143728 KB |
22 | WA | 109 ms | 143724 KB |
23 | WA | 108 ms | 143668 KB |
24 | WA | 111 ms | 143620 KB |
25 | WA | 108 ms | 143676 KB |
31 | WA | 111 ms | 143756 KB |
32 | WA | 116 ms | 143704 KB |
33 | WA | 119 ms | 143688 KB |
34 | WA | 113 ms | 143756 KB |
35 | WA | 116 ms | 143612 KB |
41 | WA | 123 ms | 143728 KB |
42 | WA | 124 ms | 143632 KB |
43 | WA | 125 ms | 143636 KB |
44 | WA | 130 ms | 143636 KB |
45 | WA | 126 ms | 143624 KB |
51 | AC | 102 ms | 143736 KB |
52 | AC | 104 ms | 143756 KB |
53 | WA | 106 ms | 143696 KB |
54 | WA | 102 ms | 143724 KB |
sample01 | AC | 106 ms | 143632 KB |
sample02 | AC | 106 ms | 143620 KB |
sample03 | AC | 102 ms | 143736 KB |