Submission #115052

# Submission time Handle Problem Language Result Execution time Memory
115052 2019-06-04T23:47:00 Z luciocf Mobile (BOI12_mobile) C++14
0 / 100
1000 ms 832 KB
#include <bits/stdc++.h>
 
#define ff first
#define ss second
 
using namespace std;
 
const int maxn = 5e3+10;
const double inf = 1e9+10;
 
typedef pair<double, double> pt;
 
int n;
double L;
 
pt p[maxn];
 
double dist(pt a, pt b)
{
	double d1 = a.ff-b.ff;
	double d2 = a.ss-b.ss;
 
	return sqrt(d1*d1 + d2*d2);
}
 
bool ok(double K)
{
	vector<double> V;
 
	for (int i = 1; i <= n; i++)
	{
		double x = p[i].ff, y = p[i].ss;
 
		double delta = sqrt(-y*y + K*K);

		double x1 = x+delta, x2 = x-delta;

		x1 = min(x1, L), x1 = max(x1, 0.00);
		x2 = min(x2, L), x2 = max(x2, 0.00);
 
		V.push_back(x1), V.push_back(x2);
	}
 
	double ans = 0.00;
 
	for (auto x: V)
	{
		double aux = inf;
 
		for (int i = 1; i <= n; i++)
			aux = min(aux, dist({x, 0.00}, p[i]));
 
		ans = max(ans, aux);
	}
 
	return (ans >= K); 
}
 
double busca(void)
{
	double ini = 0.00, fim = inf, ans = 0.00;
 
	for (int i = 1; i <= 60; i++)
	{
		double mid = (ini+fim)/2.00;
 
		if (ok(mid)) ans = mid, ini = mid;
		else fim = mid;
	}
 
	return ans;
}
 
int main(void)
{
	scanf("%d %lf\n", &n, &L);
 
	for (int i = 1; i <= n; i++)
		scanf("%lf %lf", &p[i].ff, &p[i].ss);
 
	double d1 = inf, d2 = inf;
 
	for (int i = 1; i <= n; i++)
	{
		d1 = min(d1, dist({0.00, 0.00}, p[i]));
 
		d2 = min(d2, dist({L, 0.00}, p[i]));
	}
 
	printf("%.9lf\n", max({d1, d2, busca()}));
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:76:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %lf\n", &n, &L);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
mobile.cpp:79:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lf %lf", &p[i].ff, &p[i].ss);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 780 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 784 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 832 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -