Submission #115201

# Submission time Handle Problem Language Result Execution time Memory
115201 2019-06-06T01:57:23 Z luciocf Mobile (BOI12_mobile) C++14
50 / 100
1000 ms 48320 KB
#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
 
#define ff first
#define ss second
 
using namespace std;
 
const int maxn = 1e6+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<pt> V;
 
	for (int i = 1; i <= n; i++)
	{
		double x = p[i].ff, y = p[i].ss;
 
		if (K*K < y*y)
			continue;
 
		double delta = sqrt(K*K - y*y);
 
		double x1 = x-delta, x2 = x+delta;

		V.push_back({x1, x2});
	}

	//sort(V.begin(), V.end());
 
	double r = 0.00;

	for (int i = 0; i < V.size(); i++)
		if (V[i].ff < r)
			r = max(r, V[i].ss);

	return (r <= L);
}
 
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);
 
	printf("%.9lf\n", busca());
}

Compilation message

mobile.cpp: In function 'bool ok(double)':
mobile.cpp:50:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < V.size(); i++)
                  ~~^~~~~~~~~~
mobile.cpp: In function 'int main()':
mobile.cpp:74: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:77: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 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 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 4 ms 512 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 668 KB Output is correct
2 Correct 11 ms 712 KB Output is correct
3 Correct 8 ms 628 KB Output is correct
4 Correct 6 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 708 KB Output is correct
2 Correct 12 ms 708 KB Output is correct
3 Correct 8 ms 656 KB Output is correct
4 Correct 6 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 664 KB Output is correct
2 Correct 11 ms 664 KB Output is correct
3 Correct 8 ms 668 KB Output is correct
4 Correct 5 ms 652 KB Output is correct
5 Correct 7 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 4896 KB Output is correct
2 Correct 172 ms 4928 KB Output is correct
3 Correct 95 ms 3156 KB Output is correct
4 Correct 57 ms 4836 KB Output is correct
5 Correct 55 ms 3020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 5000 KB Output is correct
2 Correct 78 ms 4692 KB Output is correct
3 Correct 70 ms 5128 KB Output is correct
4 Correct 61 ms 4948 KB Output is correct
5 Correct 56 ms 5144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 212 ms 5264 KB Output is correct
2 Correct 183 ms 5132 KB Output is correct
3 Correct 113 ms 5100 KB Output is correct
4 Correct 51 ms 5460 KB Output is correct
5 Correct 84 ms 5280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 217 ms 5624 KB Output is correct
2 Correct 220 ms 5740 KB Output is correct
3 Correct 182 ms 5580 KB Output is correct
4 Correct 52 ms 5452 KB Output is correct
5 Correct 112 ms 5588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 238 ms 5780 KB Output is correct
2 Correct 225 ms 5836 KB Output is correct
3 Correct 200 ms 5600 KB Output is correct
4 Correct 52 ms 5452 KB Output is correct
5 Correct 82 ms 5676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 24460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 24468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 35848 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 35812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 38944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 38824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 41900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 41964 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 48272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 48320 KB Time limit exceeded
2 Halted 0 ms 0 KB -