답안 #470008

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
470008 2021-09-02T15:03:30 Z Shogun3103 Mobile (BOI12_mobile) C++17
90 / 100
1000 ms 16920 KB
#include <bits/stdc++.h>
 
using namespace std;

void setIO(string fileName = ""){
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);        
    if(fileName.length()){
        freopen((fileName+".in").c_str(), "r", stdin);
        freopen((fileName+".out").c_str(), "w", stdout);
    }
}

#define ll long long
#define ld long double
#define FOR(i,a,b) for(__typeof(b) i=a; i<=b; i++)
#define FOD(i,a,b) for(__typeof(b) i=b; i>=a; i--)
#define EACH(u, v) for(auto& u : v)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,ii>
#define ld2 pair<ld, ld>
#define ll2 pair<ll, ll>
#define X first
#define Y second
#define ed "\n"
#define sp " "
const int oo = 1e9 + 7;
const int N = 1e6 + 10;

int n, len;
ll2 a[N];
ld cur;

bool calc(ld x)
{   
    FOR(i, 1, n) {
        ld delta = sqrt(x * x - a[i].Y * a[i].Y);
        ld x = a[i].X - delta, y = a[i].X + delta;
        if(x <= cur) cur = max(cur, y);
    }   
    return cur >= len;
}

void solve()
{
    cin >> n >> len;
    FOR(i, 1, n) cin >> a[i].X >> a[i].Y;

    ld l = 1, r = 1.5e9;
    while(l <= r) {
        ld m = (l + r) * 0.5;
        cur = 0;
        if(calc(m)) {
            r = m - 0.0001;
        } else {
            l = m + 0.0001;
        }
    }
    cout << fixed << setprecision(4) << l; 
}   

int main()
{ 
    setIO("");
    int t; 
    t = 1;
    //cin >> t;
    FOR(i, 1, t) {
        solve();
    }
    return 0;
}

Compilation message

mobile.cpp: In function 'void setIO(std::string)':
mobile.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen((fileName+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:9:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         freopen((fileName+".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 324 KB Output is correct
2 Correct 3 ms 308 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 460 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 6 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 6 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 6 ms 460 KB Output is correct
5 Correct 6 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 1740 KB Output is correct
2 Correct 51 ms 1752 KB Output is correct
3 Correct 39 ms 1744 KB Output is correct
4 Correct 91 ms 2512 KB Output is correct
5 Correct 46 ms 1484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 1784 KB Output is correct
2 Correct 70 ms 1660 KB Output is correct
3 Correct 85 ms 1824 KB Output is correct
4 Correct 87 ms 2664 KB Output is correct
5 Correct 96 ms 2716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 1868 KB Output is correct
2 Correct 55 ms 1840 KB Output is correct
3 Correct 65 ms 2484 KB Output is correct
4 Correct 116 ms 3012 KB Output is correct
5 Correct 90 ms 2632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 2108 KB Output is correct
2 Correct 65 ms 2116 KB Output is correct
3 Correct 73 ms 2888 KB Output is correct
4 Correct 116 ms 3024 KB Output is correct
5 Correct 100 ms 2996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 2028 KB Output is correct
2 Correct 67 ms 2016 KB Output is correct
3 Correct 73 ms 2896 KB Output is correct
4 Correct 117 ms 3024 KB Output is correct
5 Correct 101 ms 2996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 352 ms 8388 KB Output is correct
2 Correct 334 ms 8372 KB Output is correct
3 Correct 328 ms 9284 KB Output is correct
4 Correct 572 ms 9412 KB Output is correct
5 Correct 514 ms 9304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 333 ms 8384 KB Output is correct
2 Correct 505 ms 9340 KB Output is correct
3 Correct 364 ms 9412 KB Output is correct
4 Correct 569 ms 9696 KB Output is correct
5 Correct 548 ms 9356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 423 ms 10052 KB Output is correct
2 Correct 398 ms 10336 KB Output is correct
3 Correct 399 ms 10944 KB Output is correct
4 Correct 738 ms 10856 KB Output is correct
5 Correct 626 ms 10724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 390 ms 10180 KB Output is correct
2 Correct 603 ms 10784 KB Output is correct
3 Correct 444 ms 10724 KB Output is correct
4 Correct 688 ms 10964 KB Output is correct
5 Correct 631 ms 10852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 528 ms 11620 KB Output is correct
2 Correct 471 ms 11964 KB Output is correct
3 Correct 494 ms 12416 KB Output is correct
4 Correct 797 ms 12420 KB Output is correct
5 Correct 703 ms 12520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 476 ms 11756 KB Output is correct
2 Correct 701 ms 12424 KB Output is correct
3 Correct 514 ms 12296 KB Output is correct
4 Correct 816 ms 12432 KB Output is correct
5 Correct 743 ms 12416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 575 ms 13124 KB Output is correct
2 Correct 528 ms 13088 KB Output is correct
3 Correct 519 ms 13916 KB Output is correct
4 Correct 946 ms 13804 KB Output is correct
5 Correct 827 ms 13892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 548 ms 13340 KB Output is correct
2 Correct 799 ms 13740 KB Output is correct
3 Correct 612 ms 13844 KB Output is correct
4 Correct 947 ms 13772 KB Output is correct
5 Correct 823 ms 13896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 766 ms 16324 KB Output is correct
2 Correct 748 ms 16488 KB Output is correct
3 Correct 669 ms 16920 KB Output is correct
4 Execution timed out 1078 ms 16324 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 672 ms 16440 KB Output is correct
2 Execution timed out 1041 ms 16748 KB Time limit exceeded
3 Halted 0 ms 0 KB -