QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#378937 | #6401. Classic: N Real DNA Pots | gogo11# | WA | 0ms | 4400kb | C++17 | 1.3kb | 2024-04-06 15:19:17 | 2024-04-06 15:19:17 |
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 <= 35)
{
++ 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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4400kb
input:
4 3 1 2 2 4 3 3 4 1
output:
-1.008164301515
result:
wrong answer 1st numbers differ - expected: '-1.0000000', found: '-1.0081643', error = '0.0081643'