Submission #1124619

#TimeUsernameProblemLanguageResultExecution timeMemory
1124619wibulordMobile (BOI12_mobile)C++20
100 / 100
373 ms16096 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define pb emplace_back #define ii pair<int, int> #define MASK(i) (1LL << (i)) #define BIT(x, i) (((x) >> (i)) & 1) #define sz(s) (int)((s).size()) #define all(a) a.begin(), a.end() #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define F0R(i, b) for (int i = 0, _b = (b); i < _b; ++i) #define FORd(i, a, b) for (int i = (a), _b = (b); i >= _b; --i) #define F0Rd(i, b) for (int i = (b)-1; i >= 0; i--) #define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " using namespace std; template<typename T1,typename T2> bool ckmax(T1 &x,const T2 &y){if(x<y){x=y; return 1;} return 0;} template<typename T1,typename T2> bool ckmin(T1 &x,const T2 &y){if(y<x){x=y; return 1;} return 0;} const int MOD = (int)1e9 + 7; const int mod = 998244353; const int N = 1e6 + 10, M = 18; const long long INF = (long long)4e18 + 11; /* /\_/\ (= ._.) / >? \>$ */ int n, L; long long x[N], y[N]; #define SQR(x) ((x) * (x)) bool check(double d){ double lst = 0; FOR(i, 1, n){ double LEN = sqrt(SQR(d) - SQR(y[i])); if(x[i] - LEN <= lst) lst = max(lst, x[i] + LEN); } return lst >= L; } void sol(void){ cin >> n >> L; for(int i = 1; i <= n; i++) cin >> x[i] >> y[i]; double l = 0, r = 1.5e9; while(l + 1e-3 < r){ double m = (l + r) / 2; if(check(m)) r = m; else l = m; } cout << fixed << setprecision(4) << r << '\n'; } signed main(void){ #define TASK "nhap" if(fopen(TASK".inp", "r")){ freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; // cin >> t; while(t--) sol(); cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n"; }

Compilation message (stderr)

mobile.cpp: In function 'int main()':
mobile.cpp:60:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |         freopen(TASK".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen(TASK".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...