QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#179538#6401. Classic: N Real DNA Potsucup-team1001WA 1ms5776kbC++20902b2023-09-14 22:08:012023-09-14 22:08:02

Judging History

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

  • [2023-09-14 22:08:02]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5776kb
  • [2023-09-14 22:08:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n,k;
struct node
{
  long double x,y;
  bool operator<(node a)
  {
    return x<a.x;
  }
}nod[maxn];
long double d[maxn];
bool check(long double now)
{
  for(int i=1;i<=n;i++)
    d[i]=1e18;
  d[n+1]=1e18;
  d[0]=-1e18;
  for(int i=0;i<n;i++)
  {
    long double nowd=nod[i].y-now*nod[i].x;
    int p=lower_bound(d,d+n,nowd)-d;
    d[p]=nowd;
  }
  for(int i=n;i>=0;i--)
  {
    if(d[i]!=d[n+1]&&i>=k)
      return 1;
  }
  return 0;
}
long double solve()
{
  long double l=-1e18,r=1e18;
  while(r-l>1e-10)
  {
    long double m=(l+r)/2;
    if(check(m))
      l=m;
    else
      r=m;
  }
  return l;
}
int main()
{
  //freopen("1.in","r",stdin);
  cin>>n>>k;
  for(int i=0;i<n;i++)
    cin>>nod[i].x>>nod[i].y;
  sort(nod,nod+n);
  printf("%0.12lf",solve());
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5776kb

input:

4 3
1 2
2 4
3 3
4 1

output:

0.000000000000

result:

wrong answer 1st numbers differ - expected: '-1.0000000', found: '0.0000000', error = '1.0000000'