QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106842#6401. Classic: N Real DNA Potswhatever#WA 2ms3592kbC++17982b2023-05-19 15:00:302023-05-19 15:00:34

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-19 15:00:34]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3592kb
  • [2023-05-19 15:00:30]
  • 提交

answer


#include <bits/stdc++.h>

using namespace std; const int maxn = 1e5 + 5;


int n, k, sx[maxn], sy[maxn];

struct node { double x, y; } a[maxn];

double f[maxn];

inline bool check(double g)
{
  int ans = 0;
  for (int i = 1; i <= n; i++) a[i] = { sx[i], sy[i] - sx[i] * g };
//  sort(a + 1, a + n + 1, [](auto u, auto v) { return u.x < v.x; });
  for (int i = 1; i <= n; i++) f[i] = 4e18;
  for (int i = 1; i <= n; i++)
  {
//    cerr << a[i].y << ' ';
    int x = upper_bound(f + 1, f + n + 1, a[i].y) - f;
    f[x] = a[i].y;
    ans = max(ans, x);
  }
//  cerr << endl;
//  cerr << g << ' ' << ans << endl;
  return ans >= k;
}

int main()
{
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d%d", sx + i, sy + i);
//  cerr << check(-1.5) << endl;
  double l = -2e9 - 5, r = 2e9;
  for(int i=0;i<50;i++)
  {
    double mid = (l + r) * 0.5;
    if (check(mid)) l = mid; else r = mid;
  }
  return 0 * printf("%.8lf\n", l);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3592kb

input:

4 3
1 2
2 4
3 3
4 1

output:

-1.00000165

result:

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