This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <unordered_set>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <climits>
#include <queue>
#include <array>
using namespace std;
#define f first
#define s second
const int mxN = 1000;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
/*Problem: */
void solve() {}
int main()
{
ios::sync_with_stdio(0), cin.tie(0);
//freopen("paintbarn.in", "r", stdin);
//freopen("paintbarn.out", "w", stdout);
//int t = 1; cin >> t; while (t--) solve();
int n; cin >> n;
vector<int> x(n); vector<long double> dia(n);
for (int i = 0; i < n; ++i)
cin >> x[i] >> dia[i];
stack<pair<int, long double>> stk;
for (int i = 0; i < n; ++i)
{
while (!stk.empty())
{
long long x1 = stk.top().f;
long double r1 = stk.top().s;
dia[i] = min(dia[i], (x1 - x[i]) * (x1 - x[i]) / (4 * r1));
if (dia[i] >= r1) stk.pop();
else break;
}
stk.push({ x[i], dia[i] });
}
for (int i = 0; i < n; ++i)
cout << fixed << setprecision(3) << dia[i] << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |