QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#230895#6401. Classic: N Real DNA PotsLLCS#WA 1ms3960kbC++141.6kb2023-10-28 21:47:042023-10-28 21:47:04

Judging History

你现在查看的是最新测评结果

  • [2023-10-28 21:47:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3960kb
  • [2023-10-28 21:47:04]
  • 提交

answer

/*
@Date    : 2023-10-28 21:38:16
@Author  : Adscn ([email protected])
@Link    : http://www.cnblogs.com/LLCSBlog
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define IL inline
#define RG register
#define gi geti<int>()
#define gl geti<ll>()
#define gc getchar()
#define File(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
template<typename T>IL bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
template<typename T>IL bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>
IL T geti()
{
	RG T xi=0;
	RG char ch=gc;
	bool f=0;
	while(!isdigit(ch))ch=='-'?f=1:f,ch=gc;
	while(isdigit(ch))xi=xi*10+ch-48,ch=gc;
	return f?-xi:xi;
}
template<typename T>
IL void pi(T k,char ch=0)
{
	if(k<0)k=-k,putchar('-');
	if(k>=10)pi(k/10);
	putchar(k%10+'0');
	if(ch)putchar(ch);
}
/*
IL unsigned int LOG2(unsigned int x)
{
	unsigned int ret;
	__asm__ __volatile__ ("bsrl %1, %%eax":"=a"(ret):"m"(x));
	return ret;
}
*/
const int N=1e5+7;
const double eps=1e-7;
int n,k;
int px[N],py[N];
double t[N];
double dp[N];
bool check(double s)
{
	for(int i=1;i<=n;++i)t[i]=py[i]-s*px[i];
	dp[0]=-2e18;
	int len=0;
	for(int i=1;i<=n;++i){
		if(t[i]>=dp[len])dp[++len]=t[i];
		else{
			int pos=upper_bound(dp+1,dp+len+1,t[i])-dp;
			dp[pos+1]=t[i];
		}
	}
	return len>=k;
}
int main(void)
{
	#ifndef ONLINE_JUDGE
//	File("");
	#endif
	n=gi,k=gi;
	for(int i=1;i<=n;++i)px[i]=gi,py[i]=gi;
	double l=-1e9,r=1e9;
	while(l+eps<r)
	{
		double mid=(l+r)/2;
		if(check(mid))l=mid;
		else r=mid-eps;
	}
	printf("%.9f",l);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3896kb

input:

4 3
1 2
2 4
3 3
4 1

output:

-1.000000090

result:

ok found '-1.0000001', expected '-1.0000000', error '0.0000001'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

2 2
1 1
5 3

output:

0.499999872

result:

ok found '0.4999999', expected '0.5000000', error '0.0000001'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3960kb

input:

2 2
222640995 547139825
489207317 725361095

output:

0.668581295

result:

ok found '0.6685813', expected '0.6685813', error '0.0000000'

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3916kb

input:

1000 20
545612 774435015
828317 212155588
5294705 85926095
5648835 764528941
6159263 570820268
7177330 744079287
8446124 162286636
8735551 586528841
9263030 524140841
9505706 636254627
12111352 182639083
12750780 238494418
13149143 913232250
13382784 11485121
13699797 414697815
14263990 423817548
15...

output:

0.534265191

result:

wrong answer 1st numbers differ - expected: '3.7932105', found: '0.5342652', error = '0.8591522'