Created
June 6, 2015 01:28
-
-
Save balamark/81fc888175637660bd9f to your computer and use it in GitHub Desktop.
CF306 b
This file contains hidden or 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
| #include <cstdio> | |
| #include <cmath> | |
| #include <cstring> | |
| #include <ctime> | |
| #include <iostream> | |
| #include <algorithm> | |
| #include <set> | |
| #include <vector> | |
| #include <sstream> | |
| #include <typeinfo> | |
| #include <fstream> | |
| #include <unordered_map> | |
| #include <bitset> | |
| using namespace std; | |
| typedef vector<int> vi; | |
| int main(){ | |
| int n,l,r,x; | |
| cin>>n>>l>>r>>x; | |
| vi v(n, 0); | |
| for(int i=0;i<n;++i) cin>>v[i]; | |
| int cnt=0; | |
| //search all 2^n | |
| for(int i=0;i<(1<<n);++i){ | |
| int total=0; | |
| int sm = 1000000, lg = 0; | |
| for(int p=0;p<n;++p) if((1<<p)&i){ | |
| total += v[p]; | |
| sm = min(sm, v[p]); | |
| lg = max(lg, v[p]); | |
| } | |
| //check constraints | |
| if(lg-sm>=x && total<=r && total>=l) cnt++; | |
| } | |
| cout<<cnt<<endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment