General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
144740978 Practice:
hydra_cody
550B - 22 C++14 (GCC 6-32) Accepted 15 ms 8 KB 2022-01-31 19:10:51 2022-01-31 19:10:51
→ Source
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long int
#define lld long double
const int mod = 1000000007;

//-------------------------------------------------------------------------------

void solve() {
  ll n, l, r, x;
  cin>>n>>l>>r>>x;
  ll arr[n];
  for(ll i=0;i<n;i++){
    cin>>arr[i];
  }
  ll c=0;
  for(ll i=0;i<(1<<n);i++){
    ll ans=0,e=INT_MAX,h=INT_MIN;
    for(ll j=0;j<n;j++){
      if(i&(1<<j)){
        ans=(ans+arr[j]);
        if(arr[j]<e){
          e=arr[j];
        }
        if(arr[j]>h){
          h=arr[j];
        }
      }
    }
    if(e!=INT_MAX && h!=INT_MIN && ans>=l && ans<=r && (h-e)>=x){
      c++;
    }
  }
  cout<<c<<endl;

}

int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  solve();

  return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details