It has been said in the question that the minimum jar should be so that all junior chefs make their dishes. According to me, the minimum number of J should be Maximum of Ai, because if the person who requires maximum jar can cook their dish then it's possible that every junior chef can make their dishes.
but this gives me the wrong answer.
Can u guys help me to explain any test case where this logic will fail?
my code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include<bits/stdc++.h>
usingnamespace std;
int main()
{
int t;
cin>>t;
while(t--){
int n,i;
cin>>n;
int arr[n];
for(i=0;i<n;i++)
cin>>arr[i];
sort(arr,arr+n);
cout<<arr[n-1]<<endl;
}
return 0;
}
Your answer only works if the junior chefs cooperate.
> The junior chefs take some jars;
Say you have this test case
3
2 3 4
If we take your answer as 4 jars, but the distribution is actually chef1=1, chef2=1, chef3=2
They've claimed all 4 jars, but none of them can complete their task.