Submission #535225

# Submission time Handle Problem Language Result Execution time Memory
535225 2022-03-09T17:43:06 Z fcw Balloons (CEOI11_bal) C++17
10 / 100
2000 ms 6476 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]) >= 4 * r[i] * r[j];
	};
	for(int i=0;i<n;i++){
		while(!s.empty()){
			if(check(s.top(), i)) break;
			else{
				int j = s.top();
				r[i] = (x[i] - x[j]) * (x[i] - x[j]) /r[j]/ 4;
				if(r[i] > r[j]) s.pop();
			}
		}
		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 Incorrect 1 ms 204 KB 5th numbers differ - expected: '17.1630000000', found: '99.0000000000', error = '81.8370000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2074 ms 332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2061 ms 332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2057 ms 844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2078 ms 1868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2048 ms 3444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2097 ms 3916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2088 ms 5188 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2044 ms 6476 KB Time limit exceeded
2 Halted 0 ms 0 KB -