# Help me in solving FAIR_DISTRIB problem

### My issue

Can someone elpain this question in simple words?

### My code

``````#include <stdio.h>

int main(void) {
return 0;
}

``````

Problem Link: FAIR_DISTRIB Problem - CodeChef

• 01010 ← these alternate digits are always true
• Because 01 01 0
• Keeping 0 aside (since you know previous ones are increasing elements)
• So, it’s for sure that difference of consecutive elements if added will be less than or equal to last element
• So, that means these alternate digits will work out
• But, Taking ahead 1,0 like this 1 01 01 0 or 0 01 01 0 (Will also correct)
• How , Because we know difference is less than or equal to vn of alternate ones
• So, if sum of differences of alternate digits will become equal to last element in worst case
• No worries, still ahead element is always less than or equal to last element is there to make difference less than or equal to vn (last element)

Code

``````#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string str;
cin>>str;
bool flag=false;
for(int i=n-1;i>=0;i-=2)
{
if(str[i]==str[i-1]) flag|=true;
}
if(flag) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}
``````

May be it can Help

thanks for the help, i didnt understand though. Maybe its beyond my level for now.