beats 100% using binary search
Complexity
Time complexity:O(logn)

Space complexity:O(1)
Code

# Complexity
- Time complexity:O(logn)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
int possible(int mid,int &w,int &maxWeight)
{
     if(mid*w <=maxWeight)return true;
     return false;
}
    int maxContainers(int n, int w, int maxWeight) {
        
        int total_deck=n*n;
        int ans=0;
        int i=1,j=total_deck;
        while(i<=j)
        {
            int mid=i+(j-i)/2;
            if(possible(mid,w,maxWeight))
            {
                ans=mid;
                i=mid+1;
            }
            else
            {
                j=mid-1;
            }
        }
        return ans;
    }
};
```
['Binary Search', 'C++']