답안 #735127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
735127 2023-05-03T15:07:43 Z ace_in_the_hole Mobile (BOI12_mobile) C++17
0 / 100
292 ms 12044 KB
#include<bits/stdc++.h>
using namespace std;

typedef long long Int;
typedef double Real;
const Real EPS = 1e-6;
bool leq(Real x, Real y) { return x-EPS <= y; }

const int N = 1e6 + 50;
int n,L, x[N];
Int y[N];

bool check(Real dis) {
	Real rightmost = 0;
	Real d_squared = dis * dis;
	for (int i = 1; i <= n; i++) {
		if (leq(dis, y[i])) continue;
		Real lef = x[i] - sqrt(d_squared - y[i]);
		Real rig = 2*x[i] - lef;
		if (leq(lef, rightmost)) {
			rightmost = max(rightmost, rig);
			if (leq(L,rightmost)) return true;
		}
	}
	return false;
}

void solve() 
{
	cin >> n >> L;
	for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	//preprocessing
	Real max_dist = L;
	for (int i = 1; i <= n; i++) {
		y[i] *= y[i];
		int x_dis = max(abs(x[i]), abs(L - x[i]));
		Real cur_dist = sqrt(y[i] + 1ll * x_dis * x_dis);
		max_dist = max(max_dist, cur_dist);
	}
	const Real DEL = 5e-4;
	Real ans = 0;
	for (Real low = 0, high = max_dist + 100; high - low >= DEL; ) {
		Real mid = (low + high) / 2;
		if (check(mid)) high = mid;
		else ans = low = mid;
	}
	cout << fixed << setprecision(15) << ans;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	#define task "WF"
	if (fopen(task".inp", "r")) {
		freopen(task".inp", "r", stdin);
		freopen(task".out", "w", stdout);
	}
	solve();
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:57:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:58:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 1184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 1148 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1364 KB Output is correct
2 Incorrect 18 ms 1236 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 1448 KB Output is correct
2 Incorrect 19 ms 1492 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 138 ms 6112 KB Output is correct
2 Incorrect 108 ms 6064 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 123 ms 6116 KB Output is correct
2 Incorrect 95 ms 6172 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 183 ms 7452 KB Output is correct
2 Correct 141 ms 7300 KB Output is correct
3 Incorrect 111 ms 7296 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 131 ms 7472 KB Output is correct
2 Incorrect 124 ms 7272 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 216 ms 8420 KB Output is correct
2 Correct 158 ms 8504 KB Output is correct
3 Incorrect 139 ms 8484 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 172 ms 8500 KB Output is correct
2 Incorrect 148 ms 8424 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 9704 KB Output is correct
2 Incorrect 162 ms 9676 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 177 ms 9708 KB Output is correct
2 Incorrect 161 ms 9628 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 292 ms 12040 KB Output is correct
2 Correct 232 ms 11996 KB Output is correct
3 Incorrect 235 ms 11932 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 246 ms 12044 KB Output is correct
2 Incorrect 185 ms 12040 KB Output isn't correct
3 Halted 0 ms 0 KB -