답안 #465599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
465599 2021-08-16T13:44:35 Z tphuc2908 Mobile (BOI12_mobile) C++14
0 / 100
1000 ms 49948 KB
#include<bits/stdc++.h>

using namespace std;
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define repi(i,x,y) for(int i = x; i >= y; --i)
#define ci(x) int x; cin>> x
#define TC(t) ci(t); while(t--)
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define cii(x, y) ci(x); ci(y)
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
const int N = 1e6 + 5;
const int mod = 1e9+7;
const int inf = 1e9 + 5;

void readfile(){
    #ifdef ONLINE_JUDGE
    #else
        freopen("text.inp", "r", stdin);
    #endif // ONLINE_JUDGE
//    freopen("angry.in", "r", stdin);
//    freopen("angry.out", "w", stdout);
}

int n;
double L;
pair<double, double> a[N];
double pref[N];

void inp(){
    cin >> n >> L;
    rep(i,1,n){
        cii(x, y);
        a[i] = {double(x), double(y)};
    }
}

bool check(double x){
    x = x*x;
    vector<pair<double,double> > b;
    rep(i,1,n){
        if(a[i].se > x) continue;
        double temp = sqrt(x - a[i].se);
        double val = a[i].fi + temp;
        double val1 = a[i].fi - temp;
        b.pb(mp(val1, val));
    }
    sort(all(b));
    double from = 0, to = L;
    rep(i,0,n-1)
        if(b[i].fi <= from && from <= b[i].se)
            from = b[i].se;
    return from >= to;
}

void process(){
    rep(i,1,n)
        a[i].se = a[i].se*a[i].se;
    double l = 0, r = 1e9, res;
    rep(i,1,50){
        double mid = (l + r) / 2;
        if(check(mid)){
            res = mid;
            r = mid;
        }
        else l = mid;
    }
    cout << fixed << setprecision(6) << res;
}

int main(){
    //readfile();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    inp();
    process();
    return 0;
}

Compilation message

mobile.cpp: In function 'void readfile()':
mobile.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen("text.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 960 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 876 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 110 ms 5532 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 146 ms 7100 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 286 ms 5876 KB Output is correct
2 Correct 359 ms 6140 KB Output is correct
3 Runtime error 123 ms 7528 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 342 ms 7100 KB Output is correct
2 Correct 496 ms 7100 KB Output is correct
3 Runtime error 128 ms 8368 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 358 ms 7052 KB Output is correct
2 Correct 455 ms 7088 KB Output is correct
3 Runtime error 128 ms 8440 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1088 ms 26200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1090 ms 25988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1096 ms 37372 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1100 ms 37380 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1096 ms 40560 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1101 ms 40500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1095 ms 43652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1063 ms 43736 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1099 ms 49948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1095 ms 48188 KB Time limit exceeded
2 Halted 0 ms 0 KB -