Submission #570480

# Submission time Handle Problem Language Result Execution time Memory
570480 2022-05-30T07:08:30 Z lam Mobile (BOI12_mobile) C++14
27 / 100
54 ms 3728 KB
#include <bits/stdc++.h>
#define int long long
#define maxn 100010
using namespace std;
int n,L;
pair<int,int> a[maxn];
typedef long double ld;
const ld eps=1e-3;
bool cmp(pair<ld,ld> x, pair<ld,ld> y)
{
    if (x.second!=y.second) return x.second<y.second;
    return x.first<y.first;
}
bool check(ld val)
{
    vector <pair<ld,ld>> b;
    b.clear();
    val*=val;
    ld curr=0.0;
    for (int i=1; i<=n; i++)
    {
        ld temp=a[i].second;
        temp=1.0*temp*temp;
        if (temp>val) continue;
        temp=val-temp;
        temp=1.0*sqrt(temp);
        ld l=a[i].first-temp;
        ld r=a[i].first+temp;
        if (l<=curr) curr=max(curr,r);
    }
    return curr>=L;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cin>>n>>L;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i].first>>a[i].second;
    }
    ld l=0.0;
    ld r=2*1e9;
    ld ans=-1;
    while (r-l>eps)
    {
        ld mid=l+(r-l)/2;
        if (check(mid))
        {
            r=mid;
        }
        else
            l=mid;
    }
    cout<<fixed<<setprecision(3)<<l;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:44:8: warning: unused variable 'ans' [-Wunused-variable]
   44 |     ld ans=-1;
      |        ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 324 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 4 ms 596 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1368 KB Output is correct
2 Correct 37 ms 2492 KB Output is correct
3 Correct 18 ms 1700 KB Output is correct
4 Correct 23 ms 2644 KB Output is correct
5 Correct 14 ms 1504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1620 KB Output is correct
2 Correct 33 ms 2744 KB Output is correct
3 Correct 33 ms 2492 KB Output is correct
4 Correct 31 ms 3728 KB Output is correct
5 Correct 30 ms 2524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 1864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 1852 KB Output is correct
2 Correct 49 ms 3216 KB Output is correct
3 Incorrect 33 ms 2836 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 1768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1876 KB Output is correct
2 Incorrect 16 ms 1876 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 3540 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 23 ms 3588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 23 ms 3560 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 1876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1876 KB Output is correct
2 Incorrect 21 ms 1864 KB Output isn't correct
3 Halted 0 ms 0 KB -