답안 #906144

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
906144 2024-01-13T14:44:47 Z belgianbot Mobile (BOI12_mobile) C++14
100 / 100
344 ms 10692 KB
#include <bits/stdc++.h>
#define pow(x, y) (double)(pow(x, y))
using namespace std;

struct coord{
	int x, y;
};

vector <coord> a;
int N, L;
/*double dis(int ax, ay, double ans) {
	return (double)(sqrt(pow(ay, 2) + pow(ax - ans, 2)));
}
double distance(int i, int j) {
	long long num = pow(a[i].y, 2) - pow(a[j].y, 2) - pow(a[j].x, 2) + pow(a[i].x, 2);
	long long den = 2 * (-a[j].x + a[i].x);
	
	if (den == 0) return sqrt(num);
	double frac = (double)(num) / (double)(den);
	
	return frac;
}*/
bool solve(double mid) {
	double right(0);
	for (int i(0); i < a.size(); i++) {
		if (abs(a[i].y) > mid) continue;
		double iLeft = (double)(a[i].x) - (double)(sqrt(pow(mid, 2) - pow(a[i].y, 2)));
		double iRight = a[i].x + (a[i].x - iLeft);
		if (iLeft <= right) right = max(right,iRight);
	}
	return (right >= L);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> L;
	
	a.clear();
	int x, y; cin >> x >> y;
	a.push_back({x, y});
	for (int i(0); i < N - 1; i++) {
		int ax, ay;
		cin >> ax >> ay;
		if (ax == a[(int)(a.size() - 1)].x){
			if (abs(ay) < abs(a[(int)(a.size() - 1)].y)) {
				a[(int)(a.size() - 1)].x = ax;
				a[(int)(a.size() - 1)].y = ay;
			}
			else continue;
		}
		a.push_back({ax, ay});
	}
	double l(0), r(1e9);
	while (r - l > 0.0003) {
		double mid = l + (r - l) / 2;
		
		if (solve(mid)){
			 r = mid;
		 }
		else l = mid;
	}
	cout <<  setprecision(5) << fixed << l << '\n';
	return 0;
}

Compilation message

mobile.cpp: In function 'bool solve(double)':
mobile.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<coord>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for (int i(0); i < a.size(); i++) {
      |                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1604 KB Output is correct
2 Correct 19 ms 992 KB Output is correct
3 Correct 15 ms 988 KB Output is correct
4 Correct 26 ms 1496 KB Output is correct
5 Correct 9 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1244 KB Output is correct
2 Correct 17 ms 992 KB Output is correct
3 Correct 20 ms 1500 KB Output is correct
4 Correct 21 ms 1500 KB Output is correct
5 Correct 23 ms 1496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1500 KB Output is correct
2 Correct 19 ms 992 KB Output is correct
3 Correct 21 ms 1520 KB Output is correct
4 Correct 25 ms 1496 KB Output is correct
5 Correct 18 ms 988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1072 KB Output is correct
2 Correct 20 ms 1244 KB Output is correct
3 Correct 13 ms 604 KB Output is correct
4 Correct 29 ms 1524 KB Output is correct
5 Correct 24 ms 1496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1500 KB Output is correct
2 Correct 20 ms 992 KB Output is correct
3 Correct 14 ms 600 KB Output is correct
4 Correct 31 ms 1500 KB Output is correct
5 Correct 28 ms 1584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 135 ms 5584 KB Output is correct
2 Correct 73 ms 596 KB Output is correct
3 Correct 64 ms 596 KB Output is correct
4 Correct 124 ms 5152 KB Output is correct
5 Correct 120 ms 5576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 508 KB Output is correct
2 Correct 199 ms 5404 KB Output is correct
3 Correct 69 ms 1376 KB Output is correct
4 Correct 123 ms 5832 KB Output is correct
5 Correct 118 ms 5024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 167 ms 10692 KB Output is correct
2 Correct 84 ms 796 KB Output is correct
3 Correct 78 ms 548 KB Output is correct
4 Correct 153 ms 9656 KB Output is correct
5 Correct 136 ms 5672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 484 KB Output is correct
2 Correct 226 ms 9092 KB Output is correct
3 Correct 75 ms 1580 KB Output is correct
4 Correct 151 ms 10684 KB Output is correct
5 Correct 143 ms 9864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 203 ms 9288 KB Output is correct
2 Correct 90 ms 344 KB Output is correct
3 Correct 91 ms 468 KB Output is correct
4 Correct 186 ms 9664 KB Output is correct
5 Correct 149 ms 6092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 344 KB Output is correct
2 Correct 248 ms 8952 KB Output is correct
3 Correct 99 ms 1500 KB Output is correct
4 Correct 181 ms 8848 KB Output is correct
5 Correct 173 ms 10692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 240 ms 9680 KB Output is correct
2 Correct 108 ms 348 KB Output is correct
3 Correct 99 ms 496 KB Output is correct
4 Correct 222 ms 10060 KB Output is correct
5 Correct 197 ms 9976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 131 ms 344 KB Output is correct
2 Correct 278 ms 9416 KB Output is correct
3 Correct 108 ms 1488 KB Output is correct
4 Correct 202 ms 9912 KB Output is correct
5 Correct 190 ms 9152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 288 ms 8864 KB Output is correct
2 Correct 141 ms 708 KB Output is correct
3 Correct 132 ms 492 KB Output is correct
4 Correct 249 ms 10156 KB Output is correct
5 Correct 235 ms 10684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 133 ms 348 KB Output is correct
2 Correct 344 ms 9408 KB Output is correct
3 Correct 136 ms 2508 KB Output is correct
4 Correct 249 ms 10576 KB Output is correct
5 Correct 238 ms 9920 KB Output is correct