답안 #906156

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
906156 2024-01-13T14:55:30 Z belgianbot Mobile (BOI12_mobile) C++14
20 / 100
354 ms 10176 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(mid * mid - a[i].y * a[i].y));
		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)].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 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 512 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 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 2 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1500 KB Output is correct
2 Incorrect 20 ms 992 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 988 KB Output is correct
2 Correct 18 ms 988 KB Output is correct
3 Correct 21 ms 1496 KB Output is correct
4 Correct 21 ms 1500 KB Output is correct
5 Incorrect 22 ms 1500 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1576 KB Output is correct
2 Incorrect 19 ms 992 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 988 KB Output is correct
2 Incorrect 20 ms 992 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 1496 KB Output is correct
2 Incorrect 20 ms 992 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 133 ms 6088 KB Output is correct
2 Correct 64 ms 504 KB Output is correct
3 Correct 64 ms 548 KB Output is correct
4 Incorrect 119 ms 5320 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 596 KB Output is correct
2 Correct 195 ms 5708 KB Output is correct
3 Incorrect 75 ms 1384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 155 ms 8864 KB Output is correct
2 Correct 85 ms 344 KB Output is correct
3 Incorrect 77 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 344 KB Output is correct
2 Correct 230 ms 9416 KB Output is correct
3 Incorrect 79 ms 1484 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 194 ms 10040 KB Output is correct
2 Correct 88 ms 348 KB Output is correct
3 Correct 88 ms 476 KB Output is correct
4 Incorrect 166 ms 10076 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 97 ms 348 KB Output is correct
2 Correct 248 ms 10172 KB Output is correct
3 Incorrect 93 ms 1488 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 209 ms 8968 KB Output is correct
2 Correct 103 ms 504 KB Output is correct
3 Correct 103 ms 684 KB Output is correct
4 Incorrect 195 ms 9552 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 106 ms 544 KB Output is correct
2 Correct 274 ms 10176 KB Output is correct
3 Incorrect 105 ms 1552 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 260 ms 8888 KB Output is correct
2 Correct 132 ms 860 KB Output is correct
3 Incorrect 121 ms 468 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 133 ms 344 KB Output is correct
2 Correct 354 ms 8896 KB Output is correct
3 Incorrect 133 ms 2508 KB Output isn't correct
4 Halted 0 ms 0 KB -