Code forces problem bitsets

Hi,

In this problem i get wrong answer for test case 6:
and this is about bitmasks please help

https://codeforces.com/problemset/problem/550/B

MyCode:
#include<bits/stdc++.h>
using namespace std;

int main()
{
    typedef unsigned long long ull;
    ull n,mins,maxs,mindiff;
    cin >> n >> mins >> maxs >> mindiff;
    int points[n];
    for(ull i=0;i<n;++i){
        cin >> points[i];
    }
    ull c=0;
    ull res=1<<n;
    for(int i=3;i<res;++i){
        ull sum=0,temp=i,j=0,thismaxs=0,thismin=10000;
        //     cout << bitset<32>(temp);
        while(temp!=0){
            if(temp&1){
              //  cout << "points id==>" << j << "points[j]==>" << points[j] << endl;
                if(points[j]>thismaxs)thismaxs=points[j];
                if(points[j]<thismin) thismin=points[j];
                sum+=points[j];
            }
            ++j;
            temp>>=1;
        }
       // cout << "max==>" << thismaxs << "min==>" << thismin << endl;
      //  cout << sum << endl;
        //cout << (sum>=mins && sum<=maxs && (thismaxs-thismin)>=mindiff);
        if(sum>=mins && thismaxs!=0 && thismin!=10000 && sum<=maxs && (thismaxs-thismin)>=mindiff){
            ++c;
        }
       // cout << endl;
    }
    cout << c;
}

Initialize thismin with INT_MAX i.e 10^9 .
Check the range of l and r in question
My Code: https://ide.codingblocks.com/s/58472
Your corrected code:https://ide.codingblocks.com/s/58473
Hit like if u get it :slight_smile:

1 Like

Thank.:grin::heart_eyes: