Submission #1249182

#TimeUsernameProblemLanguageResultExecution timeMemory
1249182somefolkMobile (BOI12_mobile)C++20
Compilation error
0 ms0 KiB
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <complex>
#include <list>
#include <cassert>
#include <chrono>
#include <random>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define endl "\n"
#define int long long

const int INF = 1e9+7;
const int MOD = 1e9+7;

void solve(){
    int n;
    double m;
    cin >> n >> m;

    vector<pair<double, double>> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i].first >> a[i].second;
    }

    auto check = [&](double R){
        double r = 0;
        for(auto &[x, y] : a){
            int a = x-sqrt(R*R-y*y), b = x+sqrt(R*R-y*y);
            if(a <= r){
                r = max(r, b);
            }
        }

        return (r >= m);
    };

    double l = 1, r = 1.5e9, sol = 0;
    while(r-l > 1e-3){
        double mid = (l+r)/2;
        if(check(mid)){
            sol = mid;
            r = mid;
        } else {
            l = mid;
        }
    }

    cout << fixed << setprecision(4) << sol << endl;
}

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

Compilation message (stderr)

mobile.cpp: In lambda function:
mobile.cpp:42:24: error: no matching function for call to 'max(double&, long long int&)'
   42 |                 r = max(r, b);
      |                     ~~~^~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from mobile.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
mobile.cpp:42:24: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'long long int')
   42 |                 r = max(r, b);
      |                     ~~~^~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from mobile.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
mobile.cpp:42:24: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'long long int')
   42 |                 r = max(r, b);
      |                     ~~~^~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from mobile.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
mobile.cpp:42:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   42 |                 r = max(r, b);
      |                     ~~~^~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from mobile.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
mobile.cpp:42:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   42 |                 r = max(r, b);
      |                     ~~~^~~~~~