QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#378940 | #6401. Classic: N Real DNA Pots | gogo11# | WA | 1ms | 4420kb | C++17 | 1.3kb | 2024-04-06 15:19:37 | 2024-04-06 15:19:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-6
#define ll long long
#define lowbit(x) ((x) & (-x))
#define maxn 100010
struct Point
{
ll x,y;
}p[maxn];
int f[maxn],n,k;
void modify(int x, int val)
{
for(; x <= maxn; x += x & -x) f[x] = max(f[x], val);
}
ll query(int x) {
int res = 0;
for(; x; x -= x & -x) res = max(res, f[x]);
return res;
}
bool check(double x)
{
memset(f,0,sizeof(f));
vector<double> vt;
for(int i=1;i<=n;i++)
{
double now=p[i].y-p[i].x*x;
vt.push_back(now);
}
sort(vt.begin(),vt.end());
vt.erase(unique(vt.begin(),vt.end()),vt.end());
for(int i=1;i<=n;i++)
{
int id=lower_bound(vt.begin(),vt.end(),p[i].y-p[i].x*x)-vt.begin()+1;
int num=query(id);
modify(id,num+1);
}
if(query(n)>=k)
return true;
return false;
}
void solve()
{
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>p[i].x>>p[i].y;
double l=-1e9+1,r=1e9+1;
int cnt = 0;
// while((r-l)>=eps)
while(cnt <= 45)
{
++ cnt;
double mid=(l+r)/2;
if(check(mid))
l=mid;
else
r=mid;
}
cout<<fixed<<setprecision(12)<<l<<'\n';
}
int main()
{
solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4420kb
input:
4 3 1 2 2 4 3 3 4 1
output:
-1.000007270908
result:
wrong answer 1st numbers differ - expected: '-1.0000000', found: '-1.0000073', error = '0.0000073'