Submission #115200

# Submission time Handle Problem Language Result Execution time Memory
115200 2019-06-06T01:50:31 Z luciocf Mobile (BOI12_mobile) C++14
50 / 100
1000 ms 48620 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 384 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 384 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 6 ms 512 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 7 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 668 KB Output is correct
2 Correct 15 ms 728 KB Output is correct
3 Correct 19 ms 700 KB Output is correct
4 Correct 8 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 708 KB Output is correct
2 Correct 15 ms 760 KB Output is correct
3 Correct 20 ms 700 KB Output is correct
4 Correct 8 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 696 KB Output is correct
2 Correct 16 ms 764 KB Output is correct
3 Correct 23 ms 804 KB Output is correct
4 Correct 9 ms 740 KB Output is correct
5 Correct 11 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 163 ms 4908 KB Output is correct
2 Correct 378 ms 5032 KB Output is correct
3 Correct 225 ms 3268 KB Output is correct
4 Correct 102 ms 4988 KB Output is correct
5 Correct 107 ms 3152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 154 ms 5080 KB Output is correct
2 Correct 129 ms 4936 KB Output is correct
3 Correct 137 ms 5132 KB Output is correct
4 Correct 131 ms 5144 KB Output is correct
5 Correct 105 ms 5280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 321 ms 5488 KB Output is correct
2 Correct 420 ms 5300 KB Output is correct
3 Correct 494 ms 5260 KB Output is correct
4 Correct 76 ms 5624 KB Output is correct
5 Correct 165 ms 5348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 425 ms 6016 KB Output is correct
2 Correct 530 ms 5784 KB Output is correct
3 Correct 644 ms 5744 KB Output is correct
4 Correct 76 ms 5728 KB Output is correct
5 Correct 182 ms 5936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 356 ms 5824 KB Output is correct
2 Correct 527 ms 5920 KB Output is correct
3 Correct 640 ms 5736 KB Output is correct
4 Correct 78 ms 5580 KB Output is correct
5 Correct 159 ms 5728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 24576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 24644 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 35928 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 35964 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 38996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 39012 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 42232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 42200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 48620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 48440 KB Time limit exceeded
2 Halted 0 ms 0 KB -