# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
535238 |
2022-03-09T18:01:33 Z |
fcw |
Balloons (CEOI11_bal) |
C++17 |
|
205 ms |
8120 KB |
#include <bits/stdc++.h>
#define st first
#define nd second
using lint = int64_t;
constexpr int mod = int(1e9) + 7;
constexpr int inf = 0x3f3f3f3f;
constexpr int ninf = 0xcfcfcfcf;
constexpr lint linf = 0x3f3f3f3f3f3f3f3f;
const long double pi = acosl(-1.0);
// Returns -1 if a < b, 0 if a = b and 1 if a > b.
int cmp_double(double a, double b = 0, double eps = 1e-9) {
return a + eps > b ? b + eps > a ? 0 : 1 : -1;
}
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin>>n;
vector<long double>x(n), r(n);
for(int i=0;i<n;i++) cin>>x[i]>>r[i];
stack<int>s;
auto check = [&](int i, int j)->bool{
return (x[i] - x[j]) + 1e-7 >= 2 * sqrtl(r[i] * r[j]);
};
for(int i=0;i<n;i++){
while(!s.empty()){
int j = s.top();
if(check(i, j)){
if(r[i] >= r[j]) s.pop();
else break;
}
else{
r[i] = (x[i] - x[j]) * (x[i] - x[j]) /r[j]/ 4;
}
}
s.push(i);
}
cout<<fixed<<setprecision(3);
for(int i=0;i<n;i++) cout<<r[i]<<"\n";
return 0;
}
/*
[ ]Leu o problema certo???
[ ]Ver se precisa de long long
[ ]Viu o limite dos fors (é n? é m?)
[ ]Tamanho do vetor, será que é 2e5 em vez de 1e5??
[ ]Testar sample
[ ]Testar casos de borda
[ ]1LL no 1LL << i
[ ]Testar mod (é 1e9+7, mesmo?, será que o mod não ficou negativo?)
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
332 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1132 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
2408 KB |
50000 numbers |
2 |
Correct |
53 ms |
2244 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
4528 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
125 ms |
5096 KB |
115362 numbers |
2 |
Correct |
133 ms |
4784 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
163 ms |
6432 KB |
154271 numbers |
2 |
Correct |
205 ms |
7736 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
204 ms |
8120 KB |
200000 numbers |
2 |
Correct |
189 ms |
7736 KB |
199945 numbers |