QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#605299#6401. Classic: N Real DNA Potslqh2024#WA 14ms3916kbC++172.0kb2024-10-02 16:37:262024-10-02 16:37:26

Judging History

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

  • [2024-10-02 16:37:26]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3916kb
  • [2024-10-02 16:37:26]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define int long long
using i64 = long long;
mt19937_64 rd(time(0));
template <class K, class C = less<>> using paring_heap = __gnu_pbds::priority_queue<K, C>;
template <class K> using rb_tree = tree<K, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class ... A> void debug(const T & t, const A & ... a) { cerr << "[" << t, ((cerr << ", " << a), ...), cerr << "]\n"; }
const i64 mod = [](bool n) { return n ? 998244353 : 1e9 + 7; } (1);

void QAQ() {
    int n, v;
    cin >> n >> v;

    vector<array<int, 2>> a(n + 1);

    for (int i = 1; i <= n; i++) {
        cin >> a[i][0] >> a[i][1];
    }

    double l = -2e9, r = 2e9;

    auto chk = [&](double k) {
        int res = 1;
        map<double, int> q;
        q.insert({k * a[1][0] - a[1][1], 1});
        for (int i = 2; i <= n; i++) {
            double t = k * a[i][0] - a[i][1];
            auto it = q.upper_bound(t);
            if (it != q.begin()) {
                it = prev(it);
                int now = it -> second + 1;
                res = max(res, now);
                it = q.lower_bound(t);
                while (it != q.end() && it -> second <= now) {
                    it = q.erase(it);
                }
                q.insert({k * a[i][0] - a[i][1], now});
            } else {
                q.insert({k * a[i][0] - a[i][1], 1});
            }
        }
        return res >= v;
    };

    for (int i = 0; i < 200; i++) {
        auto mid = (l + r) / 2;

        if (chk(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }

    cout << l << "\n";
}

signed main() {
    cin.tie(0) -> sync_with_stdio(0);
    int t = 1;
    // cin >> t;
    for (cout << fixed << setprecision(12); t--; QAQ());
}

详细

Test #1:

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

input:

4 3
1 2
2 4
3 3
4 1

output:

-1.000000000000

result:

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

Test #2:

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

input:

2 2
1 1
5 3

output:

0.500000000000

result:

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

Test #3:

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

input:

2 2
222640995 547139825
489207317 725361095

output:

0.668581344646

result:

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

Test #4:

score: -100
Wrong Answer
time: 14ms
memory: 3916kb

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

result:

wrong answer 1st numbers differ - expected: '3.7932105', found: '-3.4053042', error = '1.8977367'