Submission #990995

#TimeUsernameProblemLanguageResultExecution timeMemory
990995chanhchuong123Mobile (BOI12_mobile)C++14
0 / 100
1020 ms8276 KiB
#include<bits/stdc++.h> using namespace std; const bool multiTest = false; #define task "" #define fi first #define se second #define MASK(i) (1LL << (i)) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define BIT(mask, i) ((mask) >> (i) & 1) template<typename T1, typename T2> bool mini(T1 &a, T2 b) { if (a > b) a = b; else return 0; return 1; } template<typename T1, typename T2> bool maxi(T1 &a, T2 b) { if (a < b) a = b; else return 0; return 1; } const int MAX = 1000100; int n, l, m; int x[MAX]; int y[MAX]; bool ok(double dist) { if (x[1] - sqrt(dist * dist - 1LL * y[1] * y[1]) >= 0) return true; if (x[m] + sqrt(dist * dist - 1LL * y[m] * y[m]) <= l) return true; for (int i = 1; i <= m - 1; ++i) { double l = x[i] + sqrt(dist * dist - 1LL * y[i] * y[i]), r = x[i + 1] - sqrt(dist * dist - 1LL * y[i + 1] * y[i + 1]); if (l <= r) return true; } return false; } void process(void) { cin >> n >> l; x[0] = -1e9 - 7; y[0] = -1e9 - 7; for (int i = 1; i <= n; ++i) { int X, Y; cin >> X >> Y; if (x[m] != X) { ++m; x[m] = X; y[m] = abs(Y); } else mini(y[m], abs(Y)); } double l = 0, r = 5 * 5e9 + 100; for (int t = 1; t <= 150; ++t) { double mid = (l + r) / 2; if (ok(mid)) l = mid; else r = mid; } cout << setprecision(6) << fixed << l; } int main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int nTest = 1; if (multiTest) cin >> nTest; while (nTest--) { process(); } return 0; }

Compilation message (stderr)

mobile.cpp: In function 'int main()':
mobile.cpp:58:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |   freopen(task".inp", "r",  stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:59:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |   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...