QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#178265#6401. Classic: N Real DNA Potsucup-team1600#WA 7ms3996kbC++202.6kb2023-09-13 20:23:472023-09-13 20:23:47

Judging History

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

  • [2023-09-13 20:23:47]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3996kb
  • [2023-09-13 20:23:47]
  • 提交

answer

//#pragma GCC optimize("Ofast", "unroll-loops")
//#pragma GCC target("sse", "sse2", "sse3", "ssse3", "sse4")
#ifdef LOCAL
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstdint>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <random>
#include <deque>
#include <functional>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <complex>
#include <numeric>
#include <cassert>
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <thread>
#else
#include <bits/stdc++.h>
#endif

#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

template<typename T>
inline bool umin(T &a, T b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
inline bool umax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#ifdef LOCAL
#define D for (bool _FLAG = true; _FLAG; _FLAG = false)
#define LOG(...) print(#__VA_ARGS__" ::", __VA_ARGS__) << endl
template <class ...Ts> auto &print(Ts ...ts) { return ((cerr << ts << " "), ...); }
#else
#define D while (false)
#define LOG(...)
#endif // LOCAL

const int max_n = -1, inf = 1000111222;

const ll linf = inf * 1ll * inf;

int main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    vector <pii> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    ld l = -inf, r = inf;
    const ld eps = 1e-7;
    while (r - l > eps) {
        ld mid = (l + r) / 2.0;
        vector <ld> dp(n + 1, linf);
        dp[0] = -inf;
        int res = 0;
        for (int i = 0; i < n; i++) {
            ld val = a[i].second - a[i].first * mid;
            int j = upper_bound(all(dp), val) - dp.begin();
            if (dp[j] > val && dp[j - 1] <= val) {
                dp[j] = val;
                umax(res, j);
            }
        }
        if (res >= k) {
            l = mid;
        }
        else {
            r = mid;
        }
    }
    cout << fixed;
    cout.precision(10);
    cout << r << '\n';
}

详细

Test #1:

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

input:

4 3
1 2
2 4
3 3
4 1

output:

-0.9999999925

result:

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

Test #2:

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

input:

2 2
1 1
5 3

output:

0.5000000240

result:

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

Test #3:

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

input:

2 2
222640995 547139825
489207317 725361095

output:

0.6685813802

result:

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

Test #4:

score: -100
Wrong Answer
time: 7ms
memory: 3816kb

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

result:

wrong answer 1st numbers differ - expected: '3.7932105', found: '3.5083627', error = '0.0750941'