QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#378922 | #6401. Classic: N Real DNA Pots | gogo11# | WA | 1ms | 4416kb | C++17 | 1.2kb | 2024-04-06 15:15:27 | 2024-04-06 15:15:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-5
#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;
while((r-l)>=eps)
{
double mid=(l+r)/2;
if(check(mid))
l=mid;
else
r=mid;
}
cout<<fixed<<setprecision(12)<<l<<'\n';
}
int main()
{
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4416kb
input:
4 3 1 2 2 4 3 3 4 1
output:
-1.000000165481
result:
ok found '-1.0000002', expected '-1.0000000', error '0.0000002'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 4248kb
input:
2 2 1 1 5 3
output:
0.499998182273
result:
wrong answer 1st numbers differ - expected: '0.5000000', found: '0.4999982', error = '0.0000018'