Created
November 5, 2014 09:21
-
-
Save KPCCoiL/28628a2b09c0a6b780bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Typical DP contest A | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int main() { | |
int n; | |
cin>>n; | |
vector<int> p(n); | |
for (auto& i : p) cin>>i; | |
vector<vector<bool>> dp(n+1, vector<bool>(10001, false)); | |
dp[0][0] = true; | |
for (auto i = 0; i < n; i++) | |
for (auto j = 10000; j >= 0; j--) | |
if (dp[i][j]) dp[i+1][j] = dp[i+1][j+p[i]] = true; | |
int cnt = 0; | |
for (auto i = 0; i <= 10000; i++) | |
if (dp[n][i]) ++cnt; | |
cout << cnt << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment