Please help me in MUFFINS3

The following is my code for this"-https://www.codechef.com/problems/MUFFINS3 " question.

#include<iostream>
using namespace std;
int main()
{
    int T;
    cin>>T;
    int arr[T];
    for(int i=0;i<T;i++)
        cin>>arr[i];
    for(int i=0;i<T;i++)
    {
        int temp=0;
        int largest=0;
    for(int j=1;j<=arr[i];j++)
    {
        static int largest=0;

        if(arr[i]%j>=largest)
        {
            largest=arr[i]%j;
            temp=j;
          
        }
    }
     cout<<temp<<endl;
}
}

I’m not getting a proper answer for dissimilar items. Can someone please point out the error in my code?

You have to tell, that how much cupcakes he must pack per package, such that remainder left is maximum. Its a trivial observation, that if we fit N/2 +1 cupcakes in a single package, we will get N/2-1 cakes leftover, which is the maximum possible value.