Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
23967 | fyq & jbh's LCA | 【BJ】T1 | C++ | 通过 | 100 | 909 MS | 128112 KB | 1919 | 2023-12-06 15:43:26 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define p_b push_back using namespace std; typedef unsigned long long ull; typedef long long ll; const int maxn=1e5+10; inline int read(){ int x=0; short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; }int n,m,dp[maxn]; struct node { int x,y; }d[maxn],t[maxn]; struct nd { double x,y; }d2[maxn]; bool operator<(node a,node b){ if(a.x!=b.x)return a.x<b.x; return a.y<b.y; } struct BIT { int t[maxn]; int lowbit(int x){return x&(-x);} void bd(){up(i,0,1e5)t[i]=0;} void upd(int x,int v){for(;x<=1e5;x+=lowbit(x))t[x]=max(t[x],v);} int qry(int x){int res=0;for(;x;x-=lowbit(x))res=max(res,t[x]);return res;} }T; bool chk(double w){ T.bd(); vector<double>px,py; up(i,1,n)d2[i].x=d[i].x-w*d[i].y,d2[i].y=d[i].x+w*d[i].y,px.p_b(d2[i].x),py.p_b(d2[i].y); up(i,1,n)if(d2[i].x>0||d2[i].y<0)return 0; sort(px.begin(),px.end()),sort(py.begin(),py.end()); up(i,1,n)t[i].x=lower_bound(px.begin(),px.end(),d2[i].x)-px.begin()+1; up(i,1,n)t[i].y=lower_bound(py.begin(),py.end(),d2[i].y)-py.begin()+1; sort(t+1,t+n+1); up(i,1,n)dp[i]=T.qry(t[i].y-1)+1,T.upd(t[i].y,dp[i]); int mx=0;up(i,1,n)mx=max(mx,dp[i]); //cout<<"test "<<mx<<'\n'; return mx<=m; } void slv(){ n=read(),m=read()+1; up(i,1,n)d[i].y=read(),d[i].x=read(); double l=0,r=1e9; while(l+0.0001<r){ double mid=(l+r)/2.0; if(chk(mid))r=mid; else l=mid; }printf("%.4f\n",r); //cout<<chk(r)<<'\n'; } int main(){ // freopen("avatar.in","r",stdin); // freopen("avatar.out","w",stdout); slv(); fclose(stdin); fclose(stdout); return 0; }