# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1075246 |
2024-08-25T21:34:35 Z |
MrPavlito |
Balloons (CEOI11_bal) |
C++17 |
|
270 ms |
14164 KB |
#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-3)
{
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 time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
9th numbers differ - expected: '82.0000000000', found: '81.9970000000', error = '0.0030000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
16th numbers differ - expected: '1.0000000000', found: '0.9980000000', error = '0.0020000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
580 KB |
5th numbers differ - expected: '117.0000000000', found: '116.9980000000', error = '0.0020000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
1624 KB |
10th numbers differ - expected: '202.0000000000', found: '201.9980000000', error = '0.0020000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
68 ms |
3924 KB |
4th numbers differ - expected: '15396.0000000000', found: '15395.9980000000', error = '0.0020000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
143 ms |
7448 KB |
13th numbers differ - expected: '7920.0000000000', found: '7919.9980000000', error = '0.0020000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
181 ms |
8528 KB |
32nd numbers differ - expected: '5025.0000000000', found: '5024.9980000000', error = '0.0020000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
228 ms |
11348 KB |
14th numbers differ - expected: '1861.0000000000', found: '1860.9980000000', error = '0.0020000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
270 ms |
14164 KB |
12th numbers differ - expected: '2950.0000000000', found: '2949.9980000000', error = '0.0020000000' |
2 |
Halted |
0 ms |
0 KB |
- |