Invitation to CodeChef Starters 196 (Rated till 5-Stars) - 23rd July

We invite you to participate in CodeChef’s Starters 196 , this Wednesday, 23rd July, rated up to 5 stars (i.e. for users with a rating < 2200).
Time: 8:00 PM — 10:00 PM IST

Joining us on the problem setting panel are:

Written editorials will be available for all on discuss.codechef.com . Pro users can find the editorials directly on the problem pages after the contest. The video editorials of the problems will be available only to Pro users.

Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef’s contests, you can share them here .
Hope to see you participating.

Good Luck!

Sugar Limit

auto solve()
{
    int n;
    cin>>n;
    vi arr;
    vi sug;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        arr.push_back(x);
    }
    for (int i = 0; i < n; i++)
    {
        int x;  cin >> x;
        sug.push_back(x);
    }
    ll sum = 0;
    int maXX_L = 0;
    vi need;
    bool flag = false;
    for(int i = 0; i < n; i++){
        if((arr[i] - sug[i]) > 0){
            sum = sum + arr[i];
            maXX_L = max(maXX_L, sug[i]);
        }
        else if ((arr[i] - sug[i]) == 0)
        {
            need.push_back(sug[i]);
        }
    }
    int evil_l = 1000;
    for(int i = 0; i < need.size(); i++){
        if(need[i] <= maXX_L){
            sum = sum + need[i];
            flag = true;
        }
        evil_l = min(evil_l, need[i]);
    }
    if((!flag) and (need.size() > 0)) return sum;
    if(sum == 0) return 0ll;
    return sum - maXX_L;
}

Anyone know why my code is failing? what testcase it is failing ? I mean I know we can brute force this but that is something I learnt from editorial.