제출 #1328608

#제출 시각아이디문제언어결과실행 시간메모리
1328608joesephdiverBalloons (CEOI11_bal)C++20
20 / 100
118 ms1968 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using ull = unsigned long long;
using ld  = long double;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
template<class T> using V = vector<T>;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
 
#define all(x)  begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x)   (int)((x).size())
 
#define pb  push_back
#define eb  emplace_back
#define mp  make_pair
 
#define rep(i,n)    for (int i = 0; i < (int)(n); ++i)
#define rep1(i,n)   for (int i = 1; i <= (int)(n); ++i)
#define forr(i,a,b) for (int i = (a); i <= (int)(b); ++i)
#define rfor(i,a,b) for (int i = (a); i >= (int)(b); --i)
 
const ll  INF64 = (1LL<<62) - 1;
const int INF   = 0x3f3f3f3f;    
const int MOD   = 1'000'000'007;
 
struct FastIO {
  FastIO() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(std::ios::fixed); cout.precision(12);
  }
} fastio;
 
inline void setIO(const string& inFile, const string& outFile){
  if (!inFile.empty())  assert(freopen(inFile.c_str(), "r", stdin)  != nullptr);
  if (!outFile.empty()) assert(freopen(outFile.c_str(), "w", stdout) != nullptr);
}
 
inline void setIO(const string& base){
  setIO(base + ".in", base + ".out");
}
 
template <class T, class U>
struct PairHash {
    std::size_t operator()(const std::pair<T, U>& p) const noexcept {
        std::size_t h1 = std::hash<T>{}(p.first);
        std::size_t h2 = std::hash<U>{}(p.second);
        return h1 ^ (h2 + 0x9e3779b9 + (h1 << 6) + (h1 >> 2));
    }
};
 
template<class T> inline bool chmin(T& a, const T& b){ if(b < a){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, const T& b){ if(a < b){ a = b; return true; } return false; }
 
template<class T> inline T ceil_div(T a, T b){
  return (a>=0 ? (a + b - 1)/b : a/b);
}
template<class T> inline T floor_div(T a, T b){
  return (a>=0 ? a/b : (a - b + 1)/b);
}
 
template<class T> inline T clampv(T x, T lo, T hi){ return x < lo ? lo : (x > hi ? hi : x); }
 
template<class T> string to_str(const T& x){ std::ostringstream os; os << x; return os.str(); }
 
template<class T>
vector<int> compress(const vector<T>& a, vector<T>* values_out=nullptr){
  vector<T> v = a; sort(all(v)); v.erase(unique(all(v)), v.end());
  if(values_out) *values_out = v;
  vector<int> id(a.size());
  rep(i, a.size()) id[i] = (int)(lower_bound(all(v), a[i]) - v.begin());
  return id;
} 
 
template<class T> istream& operator>>(istream& is, vector<T>& v){ for (auto& x : v) is >> x; return is; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v){
  for (int i = 0; i < sz(v); ++i) os << v[i] << (i+1==sz(v) ? "" : " ");
  return os;
}

template <class T, class... Rest>
auto vec(const T& value, size_t n, Rest... rest) {
    if constexpr (sizeof...(rest) == 0) {
        return vector<T>(n, value);
    } else {
        auto inner = vec<T>(value, (size_t)rest...);
        return vector<decltype(inner)>(n, inner);
    }
}
 
struct DSU {
	vi e;
	DSU(int n) : e(n, -1) {}
	bool sameSet(int a, int b) { return find(a) == find(b); }
	int size(int x) { return -e[find(x)]; }
	int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
	bool join(int a, int b) {
		a = find(a), b = find(b);
		if (a == b) return false;
		if (e[a] > e[b]) swap(a, b);
		e[a] += e[b]; e[b] = a;
		return true;
	}
};

struct SegTree {
	typedef int T;
	static constexpr T unit = INT_MAX;
	T f(T a, T b) { return min(a, b); } // (any associative fn)
	vector<T> s; int n;
	SegTree(int n = 0, T def = unit) : s(2*n, def), n(n) {}
	void update(int pos, T val) {
		for (s[pos += n] = val; pos /= 2;)
			s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
	}
	T query(int b, int e) { // query [b, e)
		T ra = unit, rb = unit;
		for (b += n, e += n; b < e; b /= 2, e /= 2) {
			if (b % 2) ra = f(ra, s[b++]);
			if (e % 2) rb = f(s[--e], rb);
		}
		return f(ra, rb);
	}
};

struct BIT {
	vector<ll> s;
	ll mod;
	BIT(int n, ll mod=0) : s(n), mod(mod) {}
	void update(int pos, ll dif) { // a[pos] += dif
		if (mod) dif %= mod, (dif < 0 ? dif += mod : 0);
		for (; pos < sz(s); pos |= pos + 1) {
			s[pos] += dif;
			if (mod) s[pos] %= mod;
		}
	}
	ll query(int pos) { // sum of values in [0, pos)
		ll res = 0;
		for (; pos > 0; pos &= pos - 1) {
			res += s[pos-1];
			if (mod) res %= mod;
		}
		return mod ? res % mod : res;
	}
	int lower_bound(ll sum) {// min pos st sum of [0, pos] >= sum
		assert(!mod); // not valid under modular arithmetic
		if (sum <= 0) return -1;
		int pos = 0;
		for (int pw = 1 << 25; pw; pw >>= 1) {
			if (pos + pw <= sz(s) && s[pos + pw-1] < sum)
				pos += pw, sum -= s[pos-1];
		}
		return pos;
	}
};
 
const int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1}, dy8[8] = {0,1,1,1,0,-1,-1,-1};
const int kx[8]  = {1,2,2,1,-1,-2,-2,-1}, ky[8] = {2,1,-1,-2,-2,-1,1,2};
 
int mod = 1000000007;

struct balloon{
	double x, r;
	double min_r(balloon& other){
		//further, smaller radius increase r
		//obviously don't keep both, so don't keep further stuff with smaller radius
		return pow(x-other.x, 2)/(4*r);
	}
};

int main(){
	int N;
	cin >> N;
	deque<balloon> d;
	cout << setprecision(3);
	rep(i, N){
		double x, r;
		cin >> x >> r;
		balloon b{x, r};
		while(d.size() >= 2 && d[1].min_r(b) <= d[0].min_r(b)) d.pop_front();
		if(!d.empty()) chmin(b.r, d[0].min_r(b));
		while(!d.empty() && b.r >= d.back().r) d.pop_back();
		d.push_back(b);
		cout << b.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...