Submission #543230

#TimeUsernameProblemLanguageResultExecution timeMemory
543230perchutsBalloons (CEOI11_bal)C++17
100 / 100
223 ms13700 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define sz(x) (int) x.size() #define endl '\n' #define pb push_back #define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; using ll = long long; using ull = unsigned long long; using ii = pair<int,int>; using iii = tuple<int,int,int>; const int inf = 2e9+1; const int mod = 1e9+7; const int maxn = 2e5+100; template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; } template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; } long double v[maxn], r[maxn], resp[maxn]; long double compute(int i,int j){ return min((v[i]-v[j])*(v[i]-v[j])/(4*resp[j]),r[i]); } int main(){_ int n;cin>>n; for(int i=1;i<=n;++i)cin>>v[i]>>r[i]; stack<int>st; for(int i=1;i<=n;++i){ double cur = r[i]; while(!st.empty()){ ckmin(cur,compute(i,st.top())); if(resp[st.top()]>=cur)break; else st.pop(); } resp[i] = cur; st.push(i); } for(int i=1;i<=n;++i)cout<<fixed<<setprecision(3)<<resp[i]<<endl; }
#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...