QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#686679#6401. Classic: N Real DNA Potslibantian#WA 1ms5932kbC++231.0kb2024-10-29 15:09:232024-10-29 15:09:24

Judging History

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

  • [2024-10-29 15:09:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5932kb
  • [2024-10-29 15:09:23]
  • 提交

answer

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

#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define fi first
#define se second
#define all(_a) _a.begin(), _a.end()
#define rep(i,p,q) for (int i=(p);i<=(q);i++)
const int N=1e5+5; const double eps=1e-10; int n,k; double b[N],f[N]; struct node{int x,y;}a[N];
int check(double x) {
    int l;
    rep(i,1,n) b[i]=a[i].y-a[i].x*x;
    f[1]=b[1],l=1;
    rep(i,2,n) 
        if (b[i]>f[l]) f[++l]=b[i];
        else {
            for (int p=1,q=l;p<q;) {
                int mid=p+q>>1;
                if (f[mid]>=b[i]) q=mid;
                else p=mid+1;
            }
            f[l]=b[i];
        }
    return l>=k;
}
signed main(){
    double s;
    scanf("%d%d",&n,&k);
    rep(i,1,n) scanf("%d%d",&a[i].x,&a[i].y);
    //sort(a+1,a+1+n,[](node a,node b){return a.x<b.x;});
    double l=-2e9,r=2e9;
    for (;r-l>eps;) {
        double mid=(l+r)/2;
        if (check(mid)) s=mid,l=mid+eps;
        else r=mid-eps;
    }
    printf("%.8lf",s);
    return 0;
}

详细

Test #1:

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

input:

4 3
1 2
2 4
3 3
4 1

output:

-1.00000000

result:

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

Test #2:

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

input:

2 2
1 1
5 3

output:

0.50000000

result:

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

Test #3:

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

input:

2 2
222640995 547139825
489207317 725361095

output:

0.66858134

result:

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

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3920kb

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:

9611.13123314

result:

wrong answer 1st numbers differ - expected: '3.7932105', found: '9611.1312331', error = '2532.7722040'