# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
925561 | May27_th | Balloons (CEOI11_bal) | C++17 | 140 ms | 11892 KiB |
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<bits/stdc++.h>
#define taskname "A"
using namespace std;
void World_Final();
void Solve();
int main(){
ios_base::sync_with_stdio(false); cin.tie(nullptr);
if (fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
World_Final();
}
void World_Final(){
int Tests = 1;
//cin >> Tests;
while (Tests --) {
Solve();
}
}
const int mod = 1e9 + 7;
struct ballon{
int64_t x; long double r;
};
long double calc(int64_t d, long double r) {
return 1.0 * d * d / (4 * r);
}
void Solve(){
int N; cin >> N;
vector<ballon> b(N);
for (auto &[x, r] : b) cin >> x >> r;
stack<pair<int64_t, long double>> s;
for (int i = 0; i < N; i ++) {
long double rmax = b[i].r;
while (!s.empty()) {
long double rmax_last = calc(b[i].x - s.top().first, s.top().second);
rmax = min(rmax, rmax_last);
if (rmax >= s.top().second) s.pop();
else break;
}
cout << fixed << setprecision(3) << rmax << "\n";
s.push(make_pair(b[i].x, rmax));
}
}
/**
A = I(i - 1, j), B = I(i, j - 1);
|I(i, j)| = |A| + |B| - |A intersect B|
**/
Compilation message (stderr)
# | 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... |