QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#470440 | #6401. Classic: N Real DNA Pots | UESTC_DebugSimulator# | WA | 1ms | 7984kb | C++17 | 1.1kb | 2024-07-10 13:38:26 | 2024-07-10 13:38:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 100010
const double eps=1e-10;
int n,K;
int x[N],y[N];
struct node{
double p;
int i;
}a[N];
bool cmp(node x,node y){
return x.p-y.p<eps;
}
int mp[N];
int tr[N];
void upd(int x){
while(x<=n){
tr[x]++;
x+=x&(-x);
}
}
int qry(int x){
int ans=0;
while(x){
ans+=tr[x];
x-=x&(-x);
}
return ans;
}
int check(double k)
{
for(int i=1;i<=n;i++){
a[i].p=k*x[i]-y[i];
a[i].i=i;
}
sort(a+1,a+1+n,cmp);
int id=0;
for(int i=1;i<=n;i++){
if(i==1||a[i].p-a[i-1].p>eps)id++;
mp[a[i].i]=id;
}
for(int i=1;i<=n;i++)tr[i]=0;
for(int i=n;i>=1;i--){
if(qry(n)-qry(mp[i]-1)>=K-1)return 1;
upd(mp[i]);
}
return 0;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n>>K;
for(int i=1;i<=n;i++)
{
cin>>x[i]>>y[i];
}
double l=-1e9,r=1e9;
for(int i=1;i<=80;i++)
{
double m=(l+r)/2;
if(check(m))
{
r=m;
}
else
{
l=m;
}
}
cout<<setprecision(10)<<l<<"\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5924kb
input:
4 3 1 2 2 4 3 3 4 1
output:
-1
result:
ok found '-1.0000000', expected '-1.0000000', error '-0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 5780kb
input:
2 2 1 1 5 3
output:
0.5
result:
ok found '0.5000000', expected '0.5000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 7984kb
input:
2 2 222640995 547139825 489207317 725361095
output:
0.6685813446
result:
ok found '0.6685813', expected '0.6685813', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 7948kb
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:
-46.1516079
result:
wrong answer 1st numbers differ - expected: '3.7932105', found: '-46.1516079', error = '13.1668988'