Submission #535235

# Submission time Handle Problem Language Result Execution time Memory
535235 2022-03-09T17:59:08 Z fcw Balloons (CEOI11_bal) C++17
60 / 100
2000 ms 10436 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]) * (x[i] - x[j]) + 1e-10 >= 4 * r[i] * r[j];
	};
	for(int i=0;i<n;i++){
		while(!s.empty()){
			int j = s.top();
			if(check(j, i)){
				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 4 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1356 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 59 ms 2944 KB 50000 numbers
2 Execution timed out 2041 ms 2784 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 120 ms 4872 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 132 ms 5524 KB 115362 numbers
2 Execution timed out 2057 ms 6364 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 180 ms 7160 KB 154271 numbers
2 Execution timed out 2041 ms 10412 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 216 ms 8772 KB 200000 numbers
2 Execution timed out 2057 ms 10436 KB Time limit exceeded
3 Halted 0 ms 0 KB -