My issue
Only 1 test case which is the final one is not passing. Can anybody find out the issue in the code ?
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
long long n;
float m;
cin>>n>>m;
long long a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
float s=0;
sort(a,a+n);
for(int i=0;i<n;i++){
s+=a[n-1]-a[i];
}
float q=(a[n-1]-a[0]);
cout<<max(q,ceil(s/m))<<endl;
}
return 0;
}
Problem Link: Make All Equal Practice Coding Problem - CodeChef