QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#625056#6401. Classic: N Real DNA PotsMartian148WA 2ms3816kbC++141.0kb2024-10-09 17:17:572024-10-09 17:17:58

Judging History

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

  • [2024-10-09 17:17:58]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3816kb
  • [2024-10-09 17:17:57]
  • 提交

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];
double a[MAXN];

int check(double mid) {
    for (int i = 1; i <= n; i++)  {
        auto [x, y] = p[i];
        a[i] = y - mid * x;
    }
    reverse(a + 1, a + 1 + n);
    vector<double> now; now.push_back(a[1]);
    for (int i = 2; i <= n; i++) {
        if (a[i] > now.back()) now.push_back(a[i]);
        int pos = lower_bound(now.begin(), now.end(), a[i]) - now.begin();
        now[pos] = a[i];
    }
    
    return now.size() >= k;
}

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("%.6lf\n", R);
    return 0;
}

详细

Test #1:

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

input:

4 3
1 2
2 4
3 3
4 1

output:

-1.000000

result:

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

Test #2:

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

input:

2 2
1 1
5 3

output:

0.500000

result:

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

Test #3:

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

input:

2 2
222640995 547139825
489207317 725361095

output:

0.668581

result:

ok found '0.6685810', expected '0.6685813', error '0.0000003'

Test #4:

score: -100
Wrong Answer
time: 2ms
memory: 3764kb

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:

-3.405304

result:

wrong answer 1st numbers differ - expected: '3.7932105', found: '-3.4053040', error = '1.8977366'