#include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> using namespace std; typedef long long int int64; int main(){ int n, l, r, x; int cc[20]; scanf("%d %d %d %d", &n, &l, &r, &x); for(int lx = 0;lx < n;lx++) scanf("%d", cc+lx); int cnt = 0; for(int sts = 0;sts < (1<<n);sts++){ int pmin = 1000000000, pmax = -1, pcnt = 0, psum = 0; for(int lx = 0;lx < n;lx++) if(sts&(1<<lx)) pcnt++, pmax = max(pmax, cc[lx]), pmin = min(pmin, cc[lx]), psum += cc[lx]; cnt += (pcnt >= 2) and (l <= psum) and (psum <= r) and (x <= pmax-pmin); } printf("%d\n", cnt); return 0; }
2015年6月30日 星期二
Codeforces Round #306 (Div. 2), problem: (B) Preparing Olympiad
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言