problem : CARRAY Problem - CodeChef
using namespace std;
int main() {
int t;std::cin >> t;
while(t--){
int n,k,b;std::cin >> n>>k>>b;
int arr[n];
for(int i=0;i<n;i++)std::cin >> arr[i];
sort(arr,arr+n,greater<int>());
int current=0;
std::vector<int>tejus ;
tejus.push_back(arr[current]);
current++;int konsa=tejus[0];
/*
y>=kx+b y-b/k >=x
*/
//binary search
while(current<n){
int temp=konsa-b;temp/=k;
int start=current;int end=n-1;
if(arr[end]<=temp){
while(start<=end&&start<n){
if(start==end){
if(arr[start]<=temp){
tejus.push_back(arr[start]);
current=start;
konsa=arr[start];break;
}
}
int mid = (start+end)/2;
if(arr[mid]==temp){
current=mid;konsa=temp;
tejus.push_back(temp);
break;
}
if(arr[mid]>temp){
start=mid+1;
}
if(arr[mid]<temp){
end=mid;
}
}current++;}
else{
break;
}
}
std::cout << tejus.size() << std::endl;
}
return 0;
}
i used binary search after attemptingin On time and getting TLE;
but getting this run time error
https://www.codechef.com/viewsolution/42013406
kindly help