Submission #115054

# Submission time Handle Problem Language Result Execution time Memory
115054 2019-06-04T23:51:28 Z luciocf Mobile (BOI12_mobile) C++14
8 / 100
1000 ms 884 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;
 
		if (K*K < y*y)
		{
			V.push_back(0.00);
			continue;
		}

		double delta = sqrt(K*K - y*y);

		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:82: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:85: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 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 256 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 10 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 696 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 700 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 884 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 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 432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 256 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 -