QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624549#6401. Classic: N Real DNA PotsMartian148WA 6ms3916kbC++14861b2024-10-09 16:04:472024-10-09 16:04:47

Judging History

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

  • [2024-10-09 16:04:47]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3916kb
  • [2024-10-09 16:04:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double INF = 1e12;

const int MAXN = 1e5 + 10;
int n, k;
pair<double, double> p[MAXN];

int check(double mid) {
    multiset<double> st;
    for (int i = n; i >= 1; i--) {
        auto [x, y] = p[i];
        int cnt = distance(st.begin(), st.upper_bound(y - mid * x));
        if (cnt + 1 >= k) return 1;
        st.insert(y - mid * x);
    }
    return 0;
}

int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        auto &[x, y] = p[i];
        cin >> x >> y;
    }
    double L = -INF, R = INF;
    while (R - L >= eps) {
        double mid = (L + R) / 2;
        if (check(mid)) R = mid;
        else L = mid;
    }
    printf("%.10lf\n", R);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3916kb

input:

4 3
1 2
2 4
3 3
4 1

output:

-1.0000000000

result:

ok found '-1.0000000', expected '-1.0000000', error '-0.0000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

2 2
1 1
5 3

output:

0.5000000000

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

2 2
222640995 547139825
489207317 725361095

output:

0.6685813447

result:

ok found '0.6685813', expected '0.6685813', error '0.0000000'

Test #4:

score: -100
Wrong Answer
time: 6ms
memory: 3792kb

input:

1000 20
545612 774435015
828317 212155588
5294705 85926095
5648835 764528941
6159263 570820268
7177330 744079287
8446124 162286636
8735551 586528841
9263030 524140841
9505706 636254627
12111352 182639083
12750780 238494418
13149143 913232250
13382784 11485121
13699797 414697815
14263990 423817548
15...

output:

-46.1516078986

result:

wrong answer 1st numbers differ - expected: '3.7932105', found: '-46.1516079', error = '13.1668988'