//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
#include <assert.h>
using namespace std;
typedef long long LL;
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18
bool f(pair<LL, long double> a, pair<LL, long double> b) {
long double bound = a.first + (long double)2 * a.second;
return b.first >= bound;
}
long double dist(pair<LL, long double> a, pair<LL, long double> b) {
long double d = abs(a.first - b.first);
return (d * d) / 4.0000 / a.second;
}
int main() {
int n; cin >> n;
vector<pair<LL, long double>> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i].first >> a[i].second;
}
vector<long double> ans(n);
ans[0] = a[0].second;
stack<pair<LL, long double>> st;
st.push(a[0]);
for (int i = 1; i < n; i++) {
long double rnow = 100000000000;
//小さいうちは潰し続ける、潰したときの半径を覚えておく
while (!st.empty() and f(st.top(),a[i])) {
rnow = min(rnow, dist(st.top(), a[i]));
st.pop();
}
if (!st.empty()) {
rnow = min(rnow, dist(st.top(), a[i]));
}
rnow = min(rnow, a[i].second);
ans[i] = rnow;
st.push({ a[i].first,rnow });
}
for (int i = 0; i < n; i++) {
cout << fixed << setprecision(3) << ans[i] << endl;
}
return 0;
}
/*
2
0 2
20 10
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
10 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
2 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
348 KB |
505 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
348 KB |
504th numbers differ - expected: '160.9360000000', found: '163.0000000000', error = '2.0640000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
44 ms |
1628 KB |
653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
138 ms |
3712 KB |
50000 numbers |
2 |
Incorrect |
122 ms |
3920 KB |
49903rd numbers differ - expected: '443977872.4679999948', found: '1000000000.0000000000', error = '556022127.5320000648' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
231 ms |
6944 KB |
14857th numbers differ - expected: '7169.6020000000', found: '7176.0000000000', error = '6.3980000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
264 ms |
7760 KB |
23610th numbers differ - expected: '1467.9600000000', found: '1471.0000000000', error = '3.0400000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
356 ms |
10320 KB |
12335th numbers differ - expected: '4957.2960000000', found: '4967.0000000000', error = '9.7040000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
451 ms |
12980 KB |
7553rd numbers differ - expected: '198.8980000000', found: '220.0000000000', error = '21.1020000000' |
2 |
Halted |
0 ms |
0 KB |
- |