답안 #989981

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
989981 2024-05-29T09:53:01 Z maithehung123 Mobile (BOI12_mobile) C++14
100 / 100
902 ms 35436 KB
#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define BIT(i) (1LL << (i))
#define GBIT(mask,i) (((mask) >> (i)) & 1)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define sz(v) ((int)v.size())
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FOD(i,a,b) for(int i = a; i >= b; --i)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 2e9 + 7;
const long long infll = 1e18 + 7;

template<class T1,class T2> bool maximize(T1 &a,T2 b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T1,class T2> bool minimize(T1 &a,T2 b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

#define MAX 1000005
int n;
int L;
pll a[MAX];

bool check(long double x) {
    long double cur = 0.0;
    FOR(i,1,n) {
        long double delta = sqrt(x * x - 1.0 * a[i].se * a[i].se);
        long double left = a[i].fi - delta,right = a[i].fi + delta;
        if(left <= cur) maximize(cur,right);
    }
    return cur >= L;
}

void process() {
    cin >> n >> L;
    FOR(i,1,n) cin >> a[i].fi >> a[i].se;
    long double l = 0,r = 1e9 + 7,mid,res;
    while(r - l >= 1e-5) {
        mid = (l + r) / 2;
        if(check(mid)) r = mid,res = mid;
        else l = mid;
    }
    cout << fixed << setprecision(6) << res;
}

int main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    #define TASK ""
    if(fopen(TASK".inp","r")) {
        freopen(TASK".inp","r",stdin);
        freopen(TASK".out","w",stdout);
    }

    if(fopen("main.inp","r")) {
        freopen("main.inp","r",stdin);
        freopen("main.out","w",stdout);
    }

    srand(time(0));

    process();

    cerr << "\n" << (double)clock() / CLOCKS_PER_SEC * 1000 << "ms";
    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:71:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         freopen(TASK".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:72:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |         freopen(TASK".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:76:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |         freopen("main.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:77:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |         freopen("main.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 360 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 1 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 5 ms 616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 4 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 5 ms 604 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 3468 KB Output is correct
2 Correct 29 ms 3928 KB Output is correct
3 Correct 24 ms 3192 KB Output is correct
4 Correct 64 ms 3676 KB Output is correct
5 Correct 32 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 3420 KB Output is correct
2 Correct 53 ms 3420 KB Output is correct
3 Correct 62 ms 3676 KB Output is correct
4 Correct 65 ms 3676 KB Output is correct
5 Correct 75 ms 3928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 3164 KB Output is correct
2 Correct 31 ms 3672 KB Output is correct
3 Correct 38 ms 3420 KB Output is correct
4 Correct 93 ms 4444 KB Output is correct
5 Correct 76 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 4228 KB Output is correct
2 Correct 38 ms 4092 KB Output is correct
3 Correct 46 ms 3676 KB Output is correct
4 Correct 95 ms 4440 KB Output is correct
5 Correct 77 ms 3932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 4184 KB Output is correct
2 Correct 35 ms 3932 KB Output is correct
3 Correct 44 ms 3724 KB Output is correct
4 Correct 92 ms 4472 KB Output is correct
5 Correct 85 ms 3932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 185 ms 12880 KB Output is correct
2 Correct 173 ms 16464 KB Output is correct
3 Correct 180 ms 15960 KB Output is correct
4 Correct 453 ms 18164 KB Output is correct
5 Correct 398 ms 15444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 166 ms 16980 KB Output is correct
2 Correct 382 ms 15440 KB Output is correct
3 Correct 224 ms 14420 KB Output is correct
4 Correct 453 ms 18172 KB Output is correct
5 Correct 433 ms 15952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 220 ms 16212 KB Output is correct
2 Correct 213 ms 20048 KB Output is correct
3 Correct 219 ms 19584 KB Output is correct
4 Correct 567 ms 22652 KB Output is correct
5 Correct 467 ms 18812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 196 ms 20564 KB Output is correct
2 Correct 491 ms 18672 KB Output is correct
3 Correct 275 ms 17492 KB Output is correct
4 Correct 567 ms 22716 KB Output is correct
5 Correct 498 ms 19612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 269 ms 18772 KB Output is correct
2 Correct 238 ms 23792 KB Output is correct
3 Correct 244 ms 22864 KB Output is correct
4 Correct 626 ms 26448 KB Output is correct
5 Correct 539 ms 21880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 232 ms 24300 KB Output is correct
2 Correct 550 ms 22352 KB Output is correct
3 Correct 313 ms 21332 KB Output is correct
4 Correct 663 ms 26412 KB Output is correct
5 Correct 548 ms 23124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 291 ms 21844 KB Output is correct
2 Correct 284 ms 27220 KB Output is correct
3 Correct 271 ms 26784 KB Output is correct
4 Correct 729 ms 30440 KB Output is correct
5 Correct 628 ms 25940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 264 ms 28280 KB Output is correct
2 Correct 594 ms 25424 KB Output is correct
3 Correct 366 ms 24520 KB Output is correct
4 Correct 725 ms 30452 KB Output is correct
5 Correct 691 ms 26584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 370 ms 24656 KB Output is correct
2 Correct 345 ms 31572 KB Output is correct
3 Correct 339 ms 30580 KB Output is correct
4 Correct 883 ms 35204 KB Output is correct
5 Correct 811 ms 29564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 329 ms 32624 KB Output is correct
2 Correct 750 ms 29308 KB Output is correct
3 Correct 440 ms 28304 KB Output is correct
4 Correct 902 ms 35436 KB Output is correct
5 Correct 778 ms 30712 KB Output is correct