Submission #13855234
Source Code Expand
Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int N,S;
const ll mo=998244353;
ll dp[3030][3030];
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N>>S;
dp[0][0]=1;
FOR(i,N) {
cin>>x;
FOR(j,S+1) {
// not
(dp[i+1][j]+=dp[i][j]*2)%=mo;
if(j+x<=S) (dp[i+1][j+x]+=dp[i][j])%=mo;
}
}
cout<<dp[N][S]<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
cout.tie(0); solve(); return 0;
}
Submission Info
Submission Time |
|
Task |
F - Knapsack for All Subsets |
User |
kmjp |
Language |
C++ (GCC 9.2.1) |
Score |
600 |
Code Size |
995 Byte |
Status |
AC |
Exec Time |
87 ms |
Memory |
74636 KB |
Compile Error
./Main.cpp: In function ‘void solve()’:
./Main.cpp:21:10: warning: unused variable ‘k’ [-Wunused-variable]
21 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp:21:12: warning: unused variable ‘l’ [-Wunused-variable]
21 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp:21:14: warning: unused variable ‘r’ [-Wunused-variable]
21 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp:21:18: warning: unused variable ‘y’ [-Wunused-variable]
21 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:7:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
7 | #define FOR(x,to) for(x=0;x<(to);x++)
| ^
./Main.cpp:40:38: note: in expansion of macro ‘FOR’
40 | FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
| ^~~
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 |
6 ms |
3796 KB |
12 |
AC |
3 ms |
4240 KB |
13 |
AC |
2 ms |
4380 KB |
14 |
AC |
3 ms |
3832 KB |
15 |
AC |
2 ms |
3716 KB |
21 |
AC |
18 ms |
16348 KB |
22 |
AC |
48 ms |
39728 KB |
23 |
AC |
37 ms |
35344 KB |
24 |
AC |
52 ms |
49436 KB |
25 |
AC |
14 ms |
10668 KB |
31 |
AC |
44 ms |
40944 KB |
32 |
AC |
53 ms |
49872 KB |
33 |
AC |
53 ms |
47452 KB |
34 |
AC |
51 ms |
48608 KB |
35 |
AC |
52 ms |
48576 KB |
41 |
AC |
85 ms |
74588 KB |
42 |
AC |
83 ms |
74588 KB |
43 |
AC |
84 ms |
74636 KB |
44 |
AC |
85 ms |
74572 KB |
45 |
AC |
87 ms |
74588 KB |
51 |
AC |
2 ms |
3628 KB |
52 |
AC |
2 ms |
3644 KB |
53 |
AC |
16 ms |
15660 KB |
54 |
AC |
18 ms |
15576 KB |
sample01 |
AC |
2 ms |
3528 KB |
sample02 |
AC |
2 ms |
3592 KB |
sample03 |
AC |
2 ms |
3692 KB |