답안 #906125

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
906125 2024-01-13T14:24:31 Z belgianbot Mobile (BOI12_mobile) C++14
100 / 100
426 ms 10684 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 1 ms 348 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 1 ms 348 KB Output is correct
2 Correct 1 ms 348 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 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 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 3 ms 568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 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 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 1500 KB Output is correct
2 Correct 25 ms 988 KB Output is correct
3 Correct 15 ms 992 KB Output is correct
4 Correct 25 ms 1500 KB Output is correct
5 Correct 14 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 992 KB Output is correct
2 Correct 17 ms 1040 KB Output is correct
3 Correct 21 ms 1580 KB Output is correct
4 Correct 32 ms 1496 KB Output is correct
5 Correct 22 ms 1496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1496 KB Output is correct
2 Correct 20 ms 988 KB Output is correct
3 Correct 21 ms 1480 KB Output is correct
4 Correct 26 ms 1504 KB Output is correct
5 Correct 19 ms 992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1112 KB Output is correct
2 Correct 20 ms 988 KB Output is correct
3 Correct 20 ms 600 KB Output is correct
4 Correct 27 ms 1788 KB Output is correct
5 Correct 28 ms 1496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1496 KB Output is correct
2 Correct 31 ms 988 KB Output is correct
3 Correct 21 ms 760 KB Output is correct
4 Correct 27 ms 1496 KB Output is correct
5 Correct 35 ms 1500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 207 ms 6412 KB Output is correct
2 Correct 65 ms 568 KB Output is correct
3 Correct 67 ms 592 KB Output is correct
4 Correct 138 ms 4948 KB Output is correct
5 Correct 148 ms 4580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 544 KB Output is correct
2 Correct 190 ms 6100 KB Output is correct
3 Correct 78 ms 1492 KB Output is correct
4 Correct 126 ms 6076 KB Output is correct
5 Correct 119 ms 5384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 167 ms 10104 KB Output is correct
2 Correct 78 ms 600 KB Output is correct
3 Correct 94 ms 788 KB Output is correct
4 Correct 189 ms 10160 KB Output is correct
5 Correct 136 ms 4804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 112 ms 504 KB Output is correct
2 Correct 239 ms 10228 KB Output is correct
3 Correct 86 ms 1588 KB Output is correct
4 Correct 196 ms 9200 KB Output is correct
5 Correct 185 ms 8636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 212 ms 9412 KB Output is correct
2 Correct 126 ms 536 KB Output is correct
3 Correct 107 ms 748 KB Output is correct
4 Correct 184 ms 8836 KB Output is correct
5 Correct 166 ms 4976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 103 ms 540 KB Output is correct
2 Correct 293 ms 9404 KB Output is correct
3 Correct 150 ms 1520 KB Output is correct
4 Correct 195 ms 9404 KB Output is correct
5 Correct 172 ms 10172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 235 ms 9956 KB Output is correct
2 Correct 115 ms 496 KB Output is correct
3 Correct 106 ms 496 KB Output is correct
4 Correct 226 ms 8868 KB Output is correct
5 Correct 216 ms 9916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 496 KB Output is correct
2 Correct 291 ms 8728 KB Output is correct
3 Correct 113 ms 1600 KB Output is correct
4 Correct 222 ms 9284 KB Output is correct
5 Correct 224 ms 9244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 331 ms 10580 KB Output is correct
2 Correct 126 ms 348 KB Output is correct
3 Correct 138 ms 444 KB Output is correct
4 Correct 268 ms 8892 KB Output is correct
5 Correct 226 ms 10684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 155 ms 496 KB Output is correct
2 Correct 426 ms 9344 KB Output is correct
3 Correct 179 ms 2452 KB Output is correct
4 Correct 266 ms 9552 KB Output is correct
5 Correct 368 ms 9920 KB Output is correct