Can anyone suggest a testcase for which my code fails? (In the problem ALIENIN)
#include <bits/stdc++.h>
#include
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
template using ordered_set = tree<T, null_type, less, rb_tree_tag, tree_order_statistics_node_update>;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T;
cin>>T;
while(T--){
int n;
double l{0},r{1e10},mid,d;
cin>>n>>d;
vector<double> c(n);
for(auto &i:c){
cin>>i;
}
sort(c.begin(),c.end());
for(int i=c.size()-1;i>=0;--i){
c[i]-=c[0];
if(i<c.size()-1){
r=max(r,max(c[i+1]-c[i],d)+1);
}
}
while(r-l>=1e-7){
mid=(l+r)/2;
double p=0;
bool poss=true;
deque<int> q;
for(int i=0;i<c.size();++i){
p=max(p,c[i]);
if(p>c[i]+d){
poss=false;
}
p+=mid;
}
if(poss){
l=mid;
}
else{
r=mid;
}
}
cout<<mid<<endl;
}
}
Thanks in advance!