Submission #570479

# Submission time Handle Problem Language Result Execution time Memory
570479 2022-05-30T07:01:36 Z lam Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 10632 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;
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();
    for (int i=1; i<=n; i++)
    {
        ld temp=a[i].second;
        temp=1.0*temp*temp;
        if (temp>val) continue;
        temp=val*val-temp;
        temp=1.0*sqrt(temp);
        ld l=a[i].first-temp;
        ld r=a[i].first+temp;
        if (r<0) continue;
        if (l>L) continue;
        b.push_back({l,r});
    }
    ld temp=0.0;
    sort(b.begin(),b.end(),cmp);
    for (int i=0; i<b.size(); i++)
    {
        if (b[i].first<=temp) temp=b[i].second;
    }
    return temp>=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;
    for (int i=1; i<=100; i++)
    {
        ld mid=l+(r-l)/2;
        if (check(mid))
        {
            ans=mid;
            r=mid;
        }
        else
            l=mid;
    }
    cout<<fixed<<setprecision(3)<<ans;
}

Compilation message

mobile.cpp: In function 'bool check(ld)':
mobile.cpp:32:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long double, long double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i=0; i<b.size(); i++)
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 287 ms 8756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 230 ms 9000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 9256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 531 ms 5176 KB Output is correct
2 Incorrect 111 ms 4968 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 139 ms 10632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 3848 KB Output is correct
2 Incorrect 21 ms 3648 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 5480 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 23 ms 5440 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 2848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 5452 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2772 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 50 ms 3876 KB Output is correct
2 Incorrect 20 ms 3640 KB Output isn't correct
3 Halted 0 ms 0 KB -