답안 #115198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
115198 2019-06-06T01:27:53 Z luciocf Mobile (BOI12_mobile) C++14
36 / 100
1000 ms 64500 KB
#include <bits/stdc++.h>
 
#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<pair<double, double>> 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({x2, x1});
	}

	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);
		else
			return true;
	}

	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);
 
	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 'bool ok(double)':
mobile.cpp:48: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: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);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 7 ms 540 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Incorrect 6 ms 512 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 700 KB Output is correct
2 Correct 15 ms 812 KB Output is correct
3 Correct 19 ms 744 KB Output is correct
4 Correct 8 ms 776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 704 KB Output is correct
2 Correct 15 ms 772 KB Output is correct
3 Correct 19 ms 744 KB Output is correct
4 Correct 8 ms 912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 752 KB Output is correct
2 Correct 15 ms 936 KB Output is correct
3 Correct 21 ms 752 KB Output is correct
4 Correct 8 ms 740 KB Output is correct
5 Correct 10 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 151 ms 5504 KB Output is correct
2 Correct 363 ms 6064 KB Output is correct
3 Correct 213 ms 3756 KB Output is correct
4 Correct 101 ms 5980 KB Output is correct
5 Correct 92 ms 3404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 152 ms 5604 KB Output is correct
2 Correct 123 ms 5508 KB Output is correct
3 Correct 129 ms 6160 KB Output is correct
4 Correct 111 ms 6356 KB Output is correct
5 Correct 100 ms 6736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 275 ms 5812 KB Output is correct
2 Correct 398 ms 6300 KB Output is correct
3 Correct 489 ms 6124 KB Output is correct
4 Incorrect 88 ms 7508 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 409 ms 6992 KB Output is correct
2 Correct 529 ms 7044 KB Output is correct
3 Correct 649 ms 6640 KB Output is correct
4 Correct 78 ms 7500 KB Output is correct
5 Correct 159 ms 6860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 321 ms 6928 KB Output is correct
2 Correct 516 ms 7336 KB Output is correct
3 Correct 650 ms 6536 KB Output is correct
4 Incorrect 80 ms 7500 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1082 ms 28712 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1070 ms 32516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 40800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1072 ms 45352 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 44744 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1087 ms 50248 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1085 ms 48888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1085 ms 54916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 56912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1069 ms 64500 KB Time limit exceeded
2 Halted 0 ms 0 KB -