QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#470461#6401. Classic: N Real DNA PotsUESTC_DebugSimulator#WA 15ms3920kbC++17781b2024-07-10 13:57:392024-07-10 13:57:39

Judging History

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

  • [2024-07-10 13:57:39]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:3920kb
  • [2024-07-10 13:57:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 100010
int n,K;
int x[N],y[N];
int check(double k)
{
	for(int ci=1;ci<=n;ci++)
	{
		int cnt=1;
		int px=x[ci],py=y[ci];
		for(int i=ci+1;i<=n;i++)
		{
			double nk=(y[i]-py)*1.0/(x[i]-px);
			if(nk<=k)
			{
				cnt++;
				px=x[i];py=y[i];
			}
		}
		if(cnt>=K) return 1;
	}
	return 0;
}
signed main()
{
	//freopen("a.in","r",stdin);
	//freopen("aa.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n>>K;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>y[i];
	}
	double l=-1e9,r=1e9;
	for(int i=1;i<=80;i++)
	{
		double m=(l+r)/2;
		if(check(m))
		{
			r=m;
		}
		else
		{
			l=m;
		}
	}
	cout<<setprecision(10)<<l<<"\n";
	return 0;
}

详细

Test #1:

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

input:

4 3
1 2
2 4
3 3
4 1

output:

-1

result:

ok found '-1.0000000', expected '-1.0000000', error '-0.0000000'

Test #2:

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

input:

2 2
1 1
5 3

output:

0.5

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #3:

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

input:

2 2
222640995 547139825
489207317 725361095

output:

0.6685813446

result:

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

Test #4:

score: -100
Wrong Answer
time: 15ms
memory: 3804kb

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.03663278059

result:

wrong answer 1st numbers differ - expected: '3.7932105', found: '0.0366328', error = '0.9903425'