QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#470704#6401. Classic: N Real DNA Potslllei#WA 1ms5824kbC++201.4kb2024-07-10 15:58:472024-07-10 15:58:47

Judging History

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

  • [2024-07-10 15:58:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5824kb
  • [2024-07-10 15:58:47]
  • 提交

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;
}

详细

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'