Submission #1075249

#TimeUsernameProblemLanguageResultExecution timeMemory
1075249MrPavlitoBalloons (CEOI11_bal)C++17
50 / 100
347 ms11348 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define sc second #define endl "\n" #define pii pair<int,int> using namespace std; const int MAXN = 2e5+5; const int mod7 = 1e9+7; const long long inf = 1e18; long double kvadrat(long double x) { return x*x; } long double solve(long double prex, long double prer, long double trx, long double mxr) { long double l = 0; long double r = mxr; while(r-l>=1e-6) { long double mid = (l+r)/2; if(kvadrat(prex-trx) + kvadrat(prer-mid) < kvadrat(mid+prer))r = mid; else l = mid; } return l; } signed main() { ios_base::sync_with_stdio(false),cin.tie(0), cout.tie(0); int tt=1; //cin >> tt; while(tt--) { int n; cin >> n; vector<long double> rovi(n); vector<long double> xovi(n); vector<long double> rez(n, inf); for(int i=0; i<n; i++)cin >> xovi[i] >> rovi[i]; stack<int> stekic; for(int i=0; i<n; i++) { while(!stekic.empty()) { long double prex = xovi[stekic.top()]; long double prer = rovi[stekic.top()]; long double trr = solve(prex,prer, xovi[i], rovi[i]); rovi[i] = min(rovi[i], trr); if(trr >= prer)stekic.pop(); else break; } rez[i] = rovi[i]; stekic.push(i); } for(int i=0; i<n; i++)cout << fixed << setprecision(3) << rez[i] << endl; } } /* 3 0 9 8 1 13 7 */
#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...