Submission #1096957

# Submission time Handle Problem Language Result Execution time Memory
1096957 2024-10-05T14:46:58 Z ocasu Mobile (BOI12_mobile) C++17
8 / 100
1000 ms 131072 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double

double mid(int x1, int y1, int x2, int y2){
    return (double)(x2*x2 - x1*x1 + y2*y2 - y1*y1)/(double)(2*x2-2*x1);
}

double dist(double x1, double y1, double x2, double y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

signed main(){
    int n,l; cin>>n>>l;
    map<int,int> mp;
    for (int i=0; i<n; i++){
        int p,q; cin>>p>>q;
        q=abs(q);
        if (mp.count(p)==0) mp[p]=q;
        mp[p] = min(mp[p], q);
    }
    n=(int)(mp.size());
    vector<int> x, y;
    for (auto [i,j]: mp){
        x.push_back(i), y.push_back(j);
    }
    vector<double> a(n,0), b(n,l);
    

    stack<int> sl;
    //cout<<'\n';
    for (int i=0; i<n; i++){
        double cur = 0;
        while (!sl.empty()) {
            cur = max(cur, mid(x[i],y[i],x[sl.top()],y[sl.top()]));
            if (y[i] >= y[sl.top()]) break;
            sl.pop();
        }
        a[i] = cur;
        //a[i] = min((double)l,a[i]);
        
        //cout<<i<<' '<<cur<<'\n';
        //ans=max(ans, dist(x[i],y[i],cur,0));
        sl.push(i);
    }
    stack<int> sr;
    //cout<<'\n';
    for (int i=n-1; i>=0; i--){
        double cur = l;
        while (!sr.empty()) {
            cur = min(cur, mid(x[i],y[i],x[sr.top()],y[sr.top()]));
            if (y[i] >= y[sr.top()]) break;
            sr.pop();
        }
        b[i] = cur;
        //b[i]=max((double)0, b[i]);

        //cout<<i<<' '<<cur<<'\n';
        //ans=max(ans, dist(x[i],y[i],cur,0));
        sr.push(i);
    }
    double ans=0;

    for (int i=0; i<n; i++){
        if (a[i]<0 or a[i]>l or b[i]<0 or b[i]>l or a[i]>b[i]) continue;
        //a[i] = min((double)l,a[i]);
        //b[i] = max((double)0, b[i]);
        ans=max(ans, dist(x[i],y[i],a[i],0));
        ans=max(ans, dist(x[i],y[i],b[i],0));
    }
    //if (ans>=12 and ans<=12.1){
    //    cout<<l<<'\n';
    //}
    cout << fixed << setprecision(6) << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 4 ms 836 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Incorrect 4 ms 860 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 8896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 69 ms 11980 KB Output is correct
2 Incorrect 60 ms 7364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 70 ms 6852 KB Output is correct
2 Incorrect 67 ms 6528 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 12988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 415 ms 67612 KB Output is correct
2 Correct 269 ms 9040 KB Output is correct
3 Correct 251 ms 8680 KB Output is correct
4 Incorrect 565 ms 64940 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 293 ms 9556 KB Output is correct
2 Incorrect 511 ms 61352 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 559 ms 81208 KB Output is correct
2 Correct 320 ms 10320 KB Output is correct
3 Correct 318 ms 9812 KB Output is correct
4 Incorrect 686 ms 78236 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 340 ms 11088 KB Output is correct
2 Incorrect 612 ms 73368 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 610 ms 94628 KB Output is correct
2 Correct 353 ms 11972 KB Output is correct
3 Correct 332 ms 11328 KB Output is correct
4 Incorrect 769 ms 90544 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 386 ms 12608 KB Output is correct
2 Incorrect 744 ms 85332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 762 ms 108268 KB Output is correct
2 Correct 417 ms 13212 KB Output is correct
3 Correct 399 ms 12632 KB Output is correct
4 Incorrect 943 ms 103648 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 424 ms 14160 KB Output is correct
2 Incorrect 791 ms 97416 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 920 ms 131072 KB Output is correct
2 Correct 487 ms 16208 KB Output is correct
3 Correct 510 ms 15444 KB Output is correct
4 Execution timed out 1064 ms 98792 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 528 ms 17304 KB Output is correct
2 Execution timed out 1046 ms 121104 KB Time limit exceeded
3 Halted 0 ms 0 KB -