답안 #920883

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
920883 2024-02-03T07:17:22 Z Kams7 Mobile (BOI12_mobile) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

double dist(double k, ll x, ll y){
    if (k<y) return -1;
    return sqrt(k*k - y*y);
}

bool check(ll n, double k, ll l, vector<pair<ll,ll>> v){
    double mn = 0;
    for (ll i=0; i<n; i++){
        ll x = v[i].first, y = v[i].second;
        double d = dist(k, x, y);
        if (d==-1) continue;
        if (x-d<=mn) mn = max(mn, x+d);
    }
    return mn>=l;
}

void solve(){
    ll n, len; cin >> n >> len;
    map<ll, ll> ys; 
    for (ll i=0; i<n; i++){
        ll x, y; cin >> x >> y;
        if (ys.find(x) == ys.end()) ys[x] = abs(y);
        else ys[x] = min(ys[x], abs(y));
    }
    vector<pair<ll, ll>> v;
    for (auto el: ys){
        v.push_back(make_pair(el.first, el.second));
    }
    sort(v.begin(), v.end());
    n = size(v);
    ll l=0, r=2*100000000000000;
    while (l<r){
        ll mid = ((l+r)/2);
        if (check(n, mid/10000.0, len, v)) r=mid;
        else l=mid+1;
    }
    cout << l/10000.0 << "\n";
}


int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	// your code goes here
	// int t;
	// cin >> t;
	// while (t--) 
    solve();
}

Compilation message

mobile.cpp: In function 'void solve()':
mobile.cpp:34:9: error: 'size' was not declared in this scope; did you mean 'dysize'?
   34 |     n = size(v);
      |         ^~~~
      |         dysize