@Alpacadh
2019-02-15T21:06:32.000000Z
字数 2657
阅读 727
ACM
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stdio.h>
#include<cstdlib>
#include<cstdio>
using namespace std;
const int inf=0x3f3f3f3f;
const int N=5e4+5;
const double eps=1e-4;
typedef long long ll;
typedef pair<int,ll> pil;
int a[N];
int n,m;
int check(int x)
{
int sum=0;
int k=0;
for(int i=1;i<=n+1;i++)
{
if(a[i]-a[k]<x)
sum++;//说明可以移除该块
else
k=i;
}
if(sum>m)
return 1;
return 0;
}
int main()
{
int ll;
scanf("%d%d%d",&ll,&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
sort(a+1,a+1+n);
a[n+1]=ll;
int l=0,r=ll;
while(l<r)
{
int mid=(l+r+1)/2;
if(check(mid))
r=mid-1;
else
l=mid;
}
printf("%d\n",l);
return 0;
}
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stdio.h>
#include<cstdlib>
#include<cstdio>
using namespace std;
const int inf=0x3f3f3f3f;
const int N=1e2+5;
const double eps=1e-4;
typedef long long ll;
typedef pair<int,ll> pil;
int n;
int cnt[N];
int b[N][N];
int p[N][N];
int ans[N*N];
double f(int x)
{
double sum=0;
for(int i=0;i<n;i++)
{
int mi=inf;
for(int j=0;j<cnt[i];j++)
{
if(ans[x]<=b[i][j])
mi=min(mi,p[i][j]);
}
sum+=mi;
}
return ans[x]/sum;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
int k=0;
for(int i=0;i<n;i++)
{
scanf("%d",&cnt[i]);
for(int j=0;j<cnt[i];j++)
{
scanf("%d%d",&b[i][j],&p[i][j]);
ans[k++]=b[i][j];
}
}
sort(ans,ans+k);
int l=0,r=k-1;
int mid,midmid;
while(l<r-1)
{
mid=(l+r)/2;
midmid=(mid+r)/2;
if(f(mid)>f(midmid))
r=midmid;
else
l=mid;
}
printf("%.3f\n",max(f(r),f(l)));
}
return 0;
}
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stdio.h>
#include<cstdlib>
#include<cstdio>
using namespace std;
const int inf=0x3f3f3f3f;
const int N=5e4+5;
const double eps=1e-4;
typedef long long ll;
typedef pair<int,ll> pil;
double H,h,D;
double f(double x)
{
return (h*D-H*x)/(D-x)+x;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf",&H,&h,&D);
double l=0,r=h/H*D;
double mid,midmid;
while(r-l>eps)
{
mid=(l+r)/2;
midmid=(mid+r)/2;
if(f(mid)<f(midmid))
l=mid;
else
r=midmid;
}
printf("%.3f\n",f(l));
}
return 0;
}