below is the question link for the question colylw

https://www.codechef.com/UAPRAC/problems/COLYLW

i have used an approach for the question in O(1) time and O(!) space and it gives right answers for all the public testcases but gives wrong answer when submitted i do not know what is wrong in my thinking please tell below is the code snippet:

the approach is :

- find the min of red blue green
- if the min id red or blue just return the min(n,red/blue) which is the required answer

3.if the min is green then there can be two cases when green is >=n in that case return min(n,green) and in the other case when green is <n then the ans will be green + some x tiles i have found those x tiles through the equation (red - green - x)+(blue-green-x)>=x

from this i get what can be the max value of x which is equal to red+blue-2*green/3.

again return the min of n and this

please tell any testcase where my code fails i am not able to get it

#include

using namespace std;

int max_cols(int n,int red,int blue,int green){

//O(1) time and O(1) space

```
int min_av=((red<blue)?((red<green)?red:green):((blue<green)?blue:green));
if(min_av==red) return min(n,red);
else if(min_av==blue) return min(n,blue);
else{
if(green>=n) return min(n,green);
else return min(n,green + (red+blue-2*green)/3);
}
return 0;
```

}

int main() {

// your code goes here

int test;

cin>>test;

```
while(test--){
int n,red,green,blue;
cin>>n>>red>>green>>blue;
cout<<max_cols(n,red,blue,green)<<endl;
}
return 0;
```

}