My issue:plz explain why my logic does not work. I have noticed the min balls of a particular element i.e the min element of array and the ans would be min element -1 since the no of boxes>=the max element of the array.
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int n,m;
cin>>n>>m;
int a[m];
for(int i=0;i<n;i++){
cin>>a[i];
}
cout<<*min_element(a,a+m)-1<<endl;
}
// your code goes here
return 0;
}
Problem Link: BLDST Problem - CodeChef