#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
#define int long long
const double INF = 1e11 + 228;
const int MAXN = 2e5 + 228;
double ans[MAXN];
signed main()
{
#ifdef LOCAL
FILE;
#endif
sh;
int n;
cin >> n;
vector<pair<int, int>> v;
for (int i = 0; i < n; i++) {
int aa, bb;
cin >> aa >> bb;
v.pb({aa, bb});
}
vector<pair<double, double>> s;
for (int i = 0; i < n; i++) {
double now = v[i].S;
for (auto to : s) {
double cl = (to.S * to.S) / (4 * to.F) + (v[i].F * v[i].F) / (4 * to.F) - (2 * v[i].F * to.S) / (4 * to.F);
now = min(now, cl);
}
while (s.size() > 0 && s.back().F <= now) {
s.pop_back();
}
ans[i] = now;
s.pb({now, (double)v[i].F});
}
for (int i = 0; i < n; i++) {
cout << fixed << setprecision(4) << ans[i] << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
10 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
2 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
376 KB |
505 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
504 KB |
2000 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
44 ms |
1372 KB |
2953rd numbers differ - expected: '1030.4380000000', found: '1030.4451000000', error = '0.0071000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2058 ms |
3064 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2035 ms |
4708 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2031 ms |
5232 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2039 ms |
6764 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2067 ms |
7860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |