4eyes4u

O(N*N/32)

Jan 15th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N=1e4+10;
  5. const int DP_SIZE=1e6;
  6.  
  7. int a[N], n;
  8.  
  9. int main()
  10. {
  11.     scanf ("%d", &n);
  12.     for (int i=1;i<=n;i++) scanf ("%d", &a[i]);
  13.  
  14.     bitset<DP_SIZE> dp;
  15.     dp.set(0);
  16.  
  17.     for (int i=1;i<=n;i++) dp|=dp<<a[i];
  18.  
  19.     cout << dp.count();
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment