QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#591063#6401. Classic: N Real DNA PotsyumingskWA 2ms3832kbC++141.7kb2024-09-26 13:53:382024-09-26 13:53:40

Judging History

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

  • [2024-09-26 13:53:40]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3832kb
  • [2024-09-26 13:53:38]
  • 提交

answer

#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
#define L_INF 0x7f3f3f3f3f3f3f3f
#define db cout << "debug\n";

using namespace std;
const int Mod = 998244353;
using ll = long long;
using ld = long double;
const ld eps = 1e-8;
int n, k;
pair<ld, ld> a[100005];
int check(ld x)
{
    int len = 1;
    vector<ld> b;
    b.push_back(a[1].second - a[1].first * x);
    // cout << b[1] << " " << x << "\n";
    for (int i = 2; i <= n; i++)
    {
        ld cur = a[i].second - a[i].first * x;
        // cout << cur << ' ' << a[i].second << ' ' << a[i].first * x << '\n';
        int pos = upper_bound(b.begin(), b.end(), cur) - b.begin();
        // cout << pos << '\n';
        if (pos == b.size())
        {
            len++;
            b.push_back(cur);
        }
        else
        {
            b[pos] = cur;
        }
    }
    return len >= k;
}
void solve()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        int x, y;
        cin >> x >> y;
        a[i] = {x, y};
    }
    ld l = -1e9;
    ld r = 1e9;
    // cout << (1 >= eps) << '\n';
    // cout << eps << '\n';
    ld ans = 0;
    while (r - l > eps)
    {
        ld mid = (l + r) / 2.0;
        if (check(mid))
        {
            ans = mid;
            l = mid;
        }
        else
        {
            r = mid;
        }
    }
    // cout << check(0.6) << '\n';
    cout << ans << '\n';
}
int main()
{
    IOS;
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

详细

Test #1:

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

input:

4 3
1 2
2 4
3 3
4 1

output:

-1

result:

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

Test #2:

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

input:

2 2
1 1
5 3

output:

0.5

result:

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

Test #3:

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

input:

2 2
222640995 547139825
489207317 725361095

output:

0.668581

result:

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

Test #4:

score: 0
Accepted
time: 1ms
memory: 3800kb

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.79321

result:

ok found '3.7932100', expected '3.7932105', error '0.0000001'

Test #5:

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

input:

1000 100
163505 684865289
2674260 837752883
2694530 150054425
2870791 236723512
3262597 800933455
3558503 905056977
4260872 45990808
4532415 268478572
5299228 546172100
6019224 12074540
6345109 747272172
6539452 449655551
7215852 676269961
9062989 769545718
9444242 874911191
10264016 341805234
10595...

output:

-1.86058

result:

wrong answer 1st numbers differ - expected: '-1.8605779', found: '-1.8605800', error = '0.0000011'