QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#470704 | #6401. Classic: N Real DNA Pots | lllei# | WA | 1ms | 5824kb | C++20 | 1.4kb | 2024-07-10 15:58:47 | 2024-07-10 15:58:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n, k;
const double eps = 1e-7;
struct A {
int x, y;
} a[100010], b[100010];
double tmp[100010];
int tree[100010], bit[100010];
int findtree(int now) {
int res = 0;
for (int i = now; i > 0; i -= bit[i]) {
res = max(res, tree[i]);
}
return res;
}
void add(int now, int num) {
for (int i = now; i <= n; i += bit[i]) {
tree[i] = max(tree[i], num);
}
}
void work() {
for (int i = 0; i < n; ++i) {
tmp[i] = b[i + 1].y;
}
sort(tmp, tmp + n);
memset(tree, 0, sizeof(tree));
for (int i = 1; i <= n; i++) {
int now = lower_bound(tmp, tmp + n, b[i].y) - tmp + 1;
int t = findtree(now) + 1;
add(now, t);
}
}
bool check(double tn) {
for (int i = 1; i <= n; i++)
b[i].x = a[i].x, b[i].y = a[i].y - a[i].x * tn;
work();
return findtree(n) >= k;
}
double find() {
double l = -1e9, r = 1e9;
while (r - l > eps) {
double mid = (l + r) / 2;
if (check(mid))
l = mid;
else
r = mid;
}
return l;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
cin >> n >> k;
for (int i = 1; i <= n; ++i) {
bit[i] = i & -i;
}
for (int i = 1; i <= n; i++)
cin >> a[i].x >> a[i].y;
cout << fixed << setprecision(10) << find() << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5824kb
input:
4 3 1 2 2 4 3 3 4 1
output:
-0.3333333609
result:
wrong answer 1st numbers differ - expected: '-1.0000000', found: '-0.3333334', error = '0.6666666'