QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#470391 | #6401. Classic: N Real DNA Pots | UESTC_xxx# | WA | 2ms | 10096kb | C++20 | 926b | 2024-07-10 12:46:43 | 2024-07-10 12:46:43 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<map>
#define ll long long
#define lowbit(x) x&(-x)
using namespace std;
int n,k;
double eps=1e-12,g[500005],a[500005];
int f[500005];
struct node{
ll x,y;
}p[500005];
bool check(double x){
for(int i=1;i<=n;++i) a[i]=p[i].y-x*p[i].x,g[i]=0;
f[1]=1;
g[1]=a[1];
g[0]=1e18;
int cnt=1;
for(int i=2;i<=n;++i){
int l=0,r=cnt+1;
while(l<r){
int mid=(l+r)/2;
if(g[mid]>=a[i]) l=mid+1;
else r=mid;
}
f[i]=l;
g[l]=max(g[l],a[i]);
cnt=max(cnt,f[i]);
}
if(cnt>=k) return 1;
return 0;
}
int main(){
scanf("%d%d",&n,&k);
for(int i=1;i<=n;++i){
scanf("%lld%lld",&p[i].x,&p[i].y);
}
double l=-1e9,r=1e9;
while(l+eps<r){
double mid=(l+r)/2.0;
if(check(mid)) r=mid;
else l=mid;
}
printf("%.12lf",l);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 10004kb
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: 1ms
memory: 10096kb
input:
2 2 1 1 5 3
output:
0.499999999999
result:
ok found '0.5000000', expected '0.5000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 9936kb
input:
2 2 222640995 547139825 489207317 725361095
output:
0.668581344645
result:
ok found '0.6685813', expected '0.6685813', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 2ms
memory: 10044kb
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.405304177949
result:
wrong answer 1st numbers differ - expected: '3.7932105', found: '-3.4053042', error = '1.8977367'