# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
607262 |
2022-07-26T14:11:00 Z |
Duy_e |
Balloons (CEOI11_bal) |
C++14 |
|
2000 ms |
2340 KB |
#include <bits/stdc++.h>
#define ll long long
#define pii pair<ll, ll>
#define st first
#define nd second
#define file "test"
using namespace std;
const long long INF = 1e18;
const long long N = 2e5 + 5;
const long long eps = 1e-6;
stack <int> st;
ll x[N], n;
double r[N];
bool touch(int i, int j) {
double c = r[i] + r[j]; c = c * c;
double a = r[i] - r[j]; a = a * a;
double b = x[j] - x[i]; b = b * b;
// cout << a << ' ' << b << ' ' << c << '\n';
return c - a >= b;
}
double cal(int i, int j) {
if (i == 0) return r[j];
double a = r[i], b = x[j] - x[i];
double ans = b * b / ((double)4.0 * a);
return min(ans, r[j]);
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
//freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
#endif
cin >> n;
st.push(0);
for (int i = 1; i <= n; i ++) {
cin >> x[i] >> r[i];
for (int j = i - 1; j >= 1; j --)
if (touch(j, i)) {
r[i] = min(r[i], cal(j, i));
}
cout << setprecision(3) << fixed << r[i] << '\n';
}
return 0;
}
/** /\_/\
* (= ._.)
* / >🍵 \>🍮
**/
Compilation message
bal.cpp:51:9: warning: "/*" within comment [-Wcomment]
51 | /** /\_/\
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
380 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
342 ms |
708 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1939 ms |
1620 KB |
50000 numbers |
2 |
Correct |
1925 ms |
2340 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2070 ms |
1460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2040 ms |
1416 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2064 ms |
1556 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2077 ms |
1524 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |