i get correct answer for test cases i tried.. still WA
spoj.pl/problems/PIE
here is my code
#include<iostream>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
vector<unsigned long long int> v;
double bin(unsigned long long int n,unsigned long long int req)
{
unsigned long long int hi,lo,x,tmp,count=0,i;
lo=v.front();
hi=v.back();
if(n==1)
return((double)v[0]/(double)req);
while(lo<hi)
{
count=0;
x=lo+(hi-lo)/2;
for(i=n-1;i>=0 && v[i]>=x;i--)
{
tmp=v[i]/x;
count+=tmp;
}
if(count>=req)
lo=x+1;
else
hi=x-1;
}
return lo-1;
}
int main()
{
unsigned long long int pi,tmp,tot,i,t;
scanf("%lld",&t);
while(t--){
scanf("%lld %lld",&pi,&tot);
tot++;
for(i=0;i<pi;i++)
{
scanf("%lld",&tmp);
v.push_back(tmp*tmp);
}
sort(v.begin(),v.end());
printf("%0.4lf\n",((M_PI*bin(pi,tot))));
v.clear();
}
}
help me out... :-)
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.