QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#106842 | #6401. Classic: N Real DNA Pots | whatever# | WA | 2ms | 3592kb | C++17 | 982b | 2023-05-19 15:00:30 | 2023-05-19 15:00:34 |
Judging History
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'