Submission #872467

#TimeUsernameProblemLanguageResultExecution timeMemory
872467sleepntsheepBalloons (CEOI11_bal)C++17
10 / 100
146 ms5992 KiB
#include <iostream> #include <iomanip> #include <cmath> #include <cstring> #include <vector> #include <algorithm> #include <deque> #include <set> #include <utility> #include <array> using i64 = long long; using u64 = unsigned long long; using f64 = double; using f80 = long double; using namespace std; #define ALL(x) x.begin(), x.end() #define ShinLena cin.tie(nullptr)->sync_with_stdio(false); #define N 200005 #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx2,tune=native") int n, x[N]; f80 r[N]; struct line { f80 m, c; int i; f80 operator[](i64 x) { return m*x+c; } f80 intersectx(const line &l) { return f80(l.c - c) / (m - l.m); } }; deque<line> lc; void add(line k) { while (lc.size()) { if (lc.back().m >= k.m) lc.pop_back(); else if (lc.size() > 1 && k.intersectx(lc.back()) <= k.intersectx(lc[lc.size()-2])) lc.pop_back(); else break; } lc.push_back(k); } f80 qry(i64 x) { u64 l = 1, r = lc.size(), z = 0; for (; l <= r;) { u64 m = (l+r)/2; if (lc[m].intersectx(lc[m-1]) <= x) z = m, l = m + 1; else r = m - 1; } return lc[z].i; } int main() { ShinLena; cin >> n; for (int i = 0; i < n; ++i) cin >> x[i] >> r[i]; add({-f80(*x)/r[0], 1L*f80(*x**x)/r[0], 0}); for (int i = 1; i < n; ++i) { int j = qry(x[i]); f80 A = (1L * x[i] * x[i] + 1L * x[j] * x[j] - 2L * x[i] * x[j]) / (4L * r[j]); r[i] = min(r[i], A); add({-f80(x[i])/r[i], f80(x[i]*x[i]) / r[i], i}); } cout << fixed << setprecision(3); for (int i = 0; i < n; ++i) cout << r[i] << '\n'; return 0; }
#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...