Submission #897273

#TimeUsernameProblemLanguageResultExecution timeMemory
897273FanOfWilliamLinBalloons (CEOI11_bal)C++14
100 / 100
149 ms7096 KiB
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define ld long double #define ar array #define vt vector #define pb push_back #define pf push_front #define lb lower_bound #define ub upper_bound #define all(v) v.begin(), v.end() ll FIRSTTRUE(function<bool(ll)> f, ll lb, ll rb) { while(lb<rb) { ll mb=(lb+rb)/2; f(mb)?rb=mb:lb=mb+1; } return lb; } ll LASTTRUE(function<bool(ll)> f, ll lb, ll rb) { while(lb<rb) { ll mb=(lb+rb+1)/2; f(mb)?lb=mb:rb=mb-1; } return lb; } const ll INF=1000000000000000000LL; const ll MOD=1e9+7; //const ll MOD=998244353; //sometimes need to be used ll bpow(ll a, ll b) { a%=MOD; ll res=1; while(b>0) { if(b&1) res=res*a%MOD; a=a*a%MOD; b>>=1; } return res; } int gcd_x, gcd_y, gcd_d; int gcd(int a, int b) { if (!b) { gcd_x=1; gcd_y=0; return a; } gcd_d=gcd(b, a%b); int tmp=gcd_x; gcd_x=gcd_y; gcd_y=tmp-(a/b)*gcd_y; return gcd_d; } const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1}; const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1}; double calc_r(pair<double, double> a, double bx) { return (a.first-bx)*(a.first-bx)/(4*a.second); } void solve() { //solve here int n; cin >> n; vt<double> ans(n); stack<pair<double, double>> st; for(int i=0; i<n; ++i) { double x, r; cin >> x >> r; double mx_r=r; while(!st.empty()) { pair<double, double> last=st.top(); double to_last_r=calc_r(last, x); mx_r=min(mx_r, to_last_r); if(mx_r>=last.second) { st.pop(); continue; } else { break; } } st.push({x, mx_r}); ans[i]=mx_r; } cout << fixed << setprecision(3); for(auto& a: ans) { cout << a << "\n"; } } signed main() { ios::sync_with_stdio(0); cin.tie(0); //freopen("template.inp", "r", stdin); //freopen("template.out", "w", stdout); int TC=1; //cin >> TC; while(TC--) { solve(); } }
#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...