QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#378937#6401. Classic: N Real DNA Potsgogo11#WA 0ms4400kbC++171.3kb2024-04-06 15:19:172024-04-06 15:19:17

Judging History

你现在查看的是最新测评结果

  • [2024-04-06 15:19:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4400kb
  • [2024-04-06 15:19:17]
  • 提交

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'