Skip to content

Instantly share code, notes, and snippets.

@taikoubou
Created February 4, 2014 13:58
Show Gist options
  • Save taikoubou/8804018 to your computer and use it in GitHub Desktop.
Save taikoubou/8804018 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<vector>
using namespace std;
void solve(int,int);
vector<int> d;
vector<int> point;
int n;
int ans=0;
int main(){
cin >> n;
for(int i=0;i<n;i++){
int temp;
cin >> temp;
d.push_back(temp);
}
solve(0,0);
cout << ans << endl;
}
void solve(int h,int p){
if(h == n){
return ;
}
else{
ans++;
solve(h+1,p);
bool f = true;
for(int i=0;i<point.size();i++){
if(point[i] == p+d[h+1])f = false;
}
if(f){
point.push_back(p+d[h+1]);
solve(h+1,p+d[h+1]);
}
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment