제출 #1300654

#제출 시각아이디문제언어결과실행 시간메모리
1300654ionut27Mobile (BOI12_mobile)C++20
0 / 100
993 ms31704 KiB
#include "bits/stdc++.h" #include <type_traits> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-loops") // ============ Macros starts here ============ int recur_depth = 0; #ifdef DEBUG #define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;} #else #define dbg(x) #endif // DEBUG template<typename Ostream, typename Cont> typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(Ostream& os, const Cont& v) { os << "{"; for (auto& x : v) { os << x << ", "; } return os << "}"; } template<typename Ostream, typename ...Ts> Ostream& operator<<(Ostream& os, const pair<Ts...>& p) { return os << "{" << p.first << ", " << p.second << "}"; } #define readFast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #ifdef LOCAL #define read() ifstream fin("date.in.txt") #else #define read() readFast #endif // LOCAL // ============ Macros ends here ============ #define fin cin #define ll long long #define sz(x) (int)(x).size() #define all(v) v.begin(), v.end() #define output(x) (((int)(x) && cout << "YES\n") || cout << "NO\n") #define LSB(x) (x & (-x)) #define test cout << "WORKS\n"; vector<pair<long double, long double>> a; int n; long double L; long double dist(int i, long double d) { // dbg(sqrt(d * d - a[i].second * a[i].second)); return sqrt(d * d - a[i].second * a[i].second); } bool check(long double d) { long double maxRight = 0; for (int i = 0; i < n; ++i) { auto c1 = dist(i, d); // cout << c1 * c1 << " " << a[i].second * a[i].second << " " << d * d << '\n'; // cout << a[i].first - c1 << " " << a[i].first + c1 << '\n'; auto left = a[i].first - c1; if (maxRight - left < 1e-3) { return false; } maxRight = max(maxRight, a[i].first + c1); } return maxRight >= L; } int main() { read(); fin >> n >> L; a.resize(n); for (int i = 0; i < n; ++i) { fin >> a[i].first >> a[i].second; } // dbg(check(5.55)); long double l = 0, r = 2 * 1e9, mid; while (r - l > 1e-3) { mid = (l + r) / 2; if (check(mid)) { r = mid; } else { l = mid; } } cout << l << '\n'; return 0; } /*stuff you should look for !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * test the solution with the given example * int overflow, array bounds, matrix bounds * special cases (n=1?) * do smth instead of nothing and stay organized * WRITE STUFF DOWN * DON'T GET STUCK ON ONE APPROACH ~Benq~*/
#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...