제출 #1238087

#제출 시각아이디문제언어결과실행 시간메모리
1238087thewizardmanBalloons (CEOI11_bal)C++20
20 / 100
155 ms8352 KiB
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template<typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define plpll pair<ll, pll>
#define pipii pair<int, pii>
#define plpii pair<ll, pii>
#define pipll pair<int, pll>
#define lll tuple<ll, ll, ll>
#define iii tuple<int, int, int>
#define lii tuple<ll, int, int>
#define lli tuple<ll, ll, int>
#define md 1000000007LL
#define linf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define lninf (ll)0xc0c0c0c0c0c0c0c0
#define ninf (int)0xc0c0c0c0
#define bruh ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss << ' ' <<
#ifdef wizard
  #define usaco(x)
#else
  #define usaco(x) ifstream cin(#x ".in"); ofstream cout(#x ".out");
#endif

template<class T1, class T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  return in >> p.first >> p.second;
}

template<class T1, class T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
  return out << p.first << ' ' << p.second;
}

template<size_t I = 0, typename... Ts>
typename enable_if<I == sizeof...(Ts), istream&>::type
read_tuple(istream& in, tuple<Ts...>& t) { return in; }

template<size_t I = 0, typename... Ts>
typename enable_if<I < sizeof...(Ts), istream&>::type
read_tuple(istream& in, tuple<Ts...>& t) {
  in >> get<I>(t);
  return read_tuple<I + 1>(in, t);
}

template<typename... Ts>
istream& operator>>(istream& in, tuple<Ts...>& t) {
  return read_tuple(in, t);
}

template<size_t I = 0, typename... Ts>
typename enable_if<I == sizeof...(Ts), void>::type
write_tuple(ostream& out, const tuple<Ts...>&) {}

template<size_t I = 0, typename... Ts>
typename enable_if<I < sizeof...(Ts), void>::type
write_tuple(ostream& out, const tuple<Ts...>& t) {
  if (I) out << ' ';
  out << get<I>(t);
  write_tuple<I + 1>(out, t);
}

template<typename... Ts>
ostream& operator<<(ostream& out, const tuple<Ts...>& t) {
  write_tuple(out, t);
  return out;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& x : v) in >> x;
  return in;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  for (size_t i = 0; i < v.size(); ++i)
    out << (i ? " " : "") << v[i];
  return out;
}

#define pld pair<ld, ld>
#define eps 1e-9
int n;
ld a[200000][2];
vector<pld> v;

inline ld eval(ld x1, ld x2, ld r1) { return (x1-x2)*(x1-x2)/r1/4.0l; }

ld ternary_search(ld x, ld def) {
  int l = 0, r = v.size()-1;
  while (r - l > 3) {
    int m1 = l + (r-l)/3;
    int m2 = r - (r-l)/3;
    if (eval(x, v[m1].first, v[m1].second) > eval(x, v[m2].first, v[m2].second)) l = m1;
    else r = m2;
  }
  ld ret = def;
  for (; l <= r; l++) ret = min(ret, eval(x, v[l].first, v[l].second));
  return ret;
}

int main() {
  bruh; cout << fixed << setprecision(3);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1];
  for (int i = 0; i < n; i++) {
    ld r = ternary_search(a[i][0], a[i][1]);
    while (v.size() && v.back().second <= r) v.pop_back();
    v.push_back({a[i][0], r});
    cout << r << '\n';
  }
}
#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...