UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#152037#8. 小w、小j和小zLightningUZ0630ms1996kbC++111.3kb2022-07-30 18:36:152022-07-30 18:36:16

answer

//#pragma GCC optimize("Ofast","inline","-ffast-math")
//#pragma GCC target("avx,sse2,sse3,sse4,mmx")
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define inf 1e8
#define rg register
using namespace std;
const int N=1e5+10;
inline ll read(){
	register ll s=0,f=0;
	register char ch=getchar();
	while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
	while(isdigit(ch)) s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
	return f?-s:s;
}
inline void write(ll x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int n,k; pair<int,int> a[N];
double b[N];
int f[N];
inline bool check(double x){
	// for(int i=1;i<=n;i++)a[i].x=a[i].p+x*a[i].v;
	for(int i=1;i<=n;++i)b[i]=a[i].first+x*a[i].second;
    int cnt=0;
    for(int i=1;i<=n;++i){f[i]=1; for(int j=1;j<i;++j)if(b[j]<=b[i]-0.001)f[i]=max(f[i],f[j]+1);}
    for(int i=1;i<=n;++i)cnt=max(cnt,f[i]);

	if(n-cnt<=k)return 1;
	return 0;
}
int main() {
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	n=read(),k=read();
	for(int i=1;i<=n;i++)a[i]={read(),read()};
	sort(a+1,a+1+n);

	double l=0,r=2e9,ans;
	while(r-l>=0.00001){
		double mid=(l+r)/2;
		if(check(mid))ans=l=mid;
		else r=mid;
	}
	if(ans>=2e9-0.0001)printf("Forever");
	else printf("%.4lf",l);
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1980kb

input:

20 10
-715624307 -28629151
957936621 17210368
-753657459 59049
-40974960 5153632
-402454312 -3450252...

output:

0.1795

result:

wrong answer expected 11.3999000000, found 0.1795000000

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 3ms
memory: 1984kb

input:

200 10
-487405787 3200000
725249085 28629151
-671026855 -4084101
38046635 45435424
-188495128 643634...

output:

0.0000

result:

wrong answer expected 0.0039000000, found 0.0000000000

Subtask #3:

score: 0
Skipped

Subtask #4:

score: 0
Wrong Answer

Test #18:

score: 15
Accepted
time: 187ms
memory: 1992kb

input:

2000 10
882856800 -387420489
866607093 -134217728
481381898 1
-488180557 1953125
-783185249 -19683
-...

output:

0.0000

result:

ok answer is 0.0001000000

Test #19:

score: 0
Accepted
time: 221ms
memory: 1992kb

input:

2000 10
882856800 -177147
866607093 -48828125
481381898 1
-488180557 48828125
-783185249 -362797056
...

output:

0.0000

result:

ok answer is 0.0001000000

Test #20:

score: -15
Wrong Answer
time: 219ms
memory: 1996kb

input:

2000 10
882856800 -1
866607093 -396
481381898 21
-488180557 6
-783185249 -10
-816111307 -33761
99248...

output:

0.0000

result:

wrong answer expected 2.6237000000, found 0.0000000000

Subtask #5:

score: 0
Skipped

Subtask #6:

score: 0
Skipped