QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#109651#6401. Classic: N Real DNA PotsHvianna22WA 24ms3908kbC++231.0kb2023-05-30 02:05:462023-05-30 02:05:47

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-30 02:05:47]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:3908kb
  • [2023-05-30 02:05:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int MAX = 3e6 + 15;
const double INF = 2e10;

#define int long long int
#define double long double

int n, k;
double x[MAX], y[MAX];

int getLis(vector<double>& v){
    int n = v.size(), maxLis = 0;
    vector<double> dp(n + 1, INF);

    dp[0] = -INF;

    for(int i = 0; i < n; i++){
        int curLis = upper_bound(dp.begin(), dp.end(), v[i]) - dp.begin();
        dp[curLis] = min(dp[curLis], v[i]);

        maxLis = max(maxLis, curLis);
    }

    return maxLis;
}

int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k;

    for(int i = 1; i <= n; i++)
        cin >> x[i] >> y[i];

    double l = -INF, r = INF;

    for(int i = 0; i < 100; i++){
        double m = (l + r) / 2.0;

        vector<double> cur;
        for(int i = 1; i <= n; i++)
            cur.emplace_back(y[i] - m * x[i]);

        if(getLis(cur) >= k) l = m;
        else r = m;
    }

    cout << setprecision(10) << fixed << l << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 2ms
memory: 3652kb

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: 1ms
memory: 3596kb

input:

2 2
222640995 547139825
489207317 725361095

output:

0.6685813446

result:

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

Test #4:

score: 0
Accepted
time: 3ms
memory: 3680kb

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

result:

ok found '3.7932105', expected '3.7932105', error '0.0000000'

Test #5:

score: 0
Accepted
time: 9ms
memory: 3668kb

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

result:

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

Test #6:

score: -100
Wrong Answer
time: 24ms
memory: 3908kb

input:

5000 10
34774 620025564
366562 278306777
446710 509672662
650220 70882120
824803 317731338
881144 257861254
1063458 61483347
1071840 639872836
1263842 30790337
1591940 346781076
1964777 814735151
2067497 63962255
2220071 379252135
2539054 428050443
2937092 423099578
3088992 959927412
3229098 9591796...

output:

124.0730101443

result:

wrong answer 1st numbers differ - expected: '134.6214728', found: '124.0730101', error = '0.0783565'