답안 #972685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972685 2024-04-30T21:40:39 Z iag99 Mobile (BOI12_mobile) C++17
66 / 100
413 ms 21396 KB
#include <bits/stdc++.h>
#define long long long

using namespace std;

struct Point{
	double x,y;
};
double max_point(const Point &a, const Point &b)
{
	return (b.x * b.x + b.y * b.y - a.x * a.x - a.y * a.y) /
	       (2 * b.x - 2 * a.x);
}
double dist(const Point &a, const Point &b) {
	return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,l;
	cin>>n>>l;
	deque<Point> needed;
	for(int i=0; i<n; i++)
	{
		Point cur;
		cin>>cur.x>>cur.y;
		cur.y=abs(cur.y);
		if((int)needed.size() && needed.back().x==cur.x)
		{
			if(cur.y>=needed.back().y)
			{
				continue;
			}
			else
			{
				needed.pop_back();
			}
		}
		while((int)needed.size()>1 && max_point(needed[needed.size()-2], needed.back())>max_point(needed.back(),cur))
		{
			needed.pop_back();
		}
		needed.push_back(cur);
		
	}
	while ((int)needed.size() > 1 && max_point(needed[0], needed[1]) < 0) {
		needed.pop_front();
	}

	while ((int)needed.size() > 1 &&
	       max_point(needed[(int)needed.size() - 2], needed.back()) > l) {
		needed.pop_back();
	}
	double ans=0;
	for(int x=0; x<(int)needed.size(); x++)
	{
		Point left={0,0};
		Point right={l,0};
		if (x) { left.x = max_point(needed[x], needed[x - 1]); }
		if (x < (int)needed.size() - 1) {
			right.x = max_point(needed[x], needed[x + 1]);
		}

		if (left.x < 0 || right.x > l || right.x < 0 || left.x > l) {
			continue;
		}
		if(left.x>=0 && left.x<=l) ans=max(ans, dist(needed[x], left));
		if(right.x>=0 && right.x<=l) ans=max(ans, dist(needed[x], left));
		//ans = max({ans, dist(needed[x], left), dist(needed[x], right)});
	}
		cout << fixed << setprecision(6) << ans << endl;

	
	return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:59:16: warning: narrowing conversion of 'l' from 'int' to 'double' [-Wnarrowing]
   59 |   Point right={l,0};
      |                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 2 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 3 ms 344 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 3 ms 344 KB Output is correct
2 Correct 2 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 2 ms 348 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 2 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1116 KB Output is correct
2 Correct 31 ms 1116 KB Output is correct
3 Correct 19 ms 856 KB Output is correct
4 Correct 30 ms 1116 KB Output is correct
5 Correct 16 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 860 KB Output is correct
2 Correct 25 ms 1116 KB Output is correct
3 Correct 32 ms 1364 KB Output is correct
4 Correct 31 ms 1116 KB Output is correct
5 Correct 35 ms 1456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 2224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 1372 KB Output is correct
2 Correct 35 ms 1464 KB Output is correct
3 Correct 40 ms 1792 KB Output is correct
4 Correct 56 ms 1588 KB Output is correct
5 Correct 37 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 2384 KB Output is correct
2 Correct 36 ms 1368 KB Output is correct
3 Correct 31 ms 1368 KB Output is correct
4 Correct 52 ms 1872 KB Output is correct
5 Correct 37 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 170 ms 10836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 186 ms 4788 KB Output is correct
2 Correct 180 ms 4704 KB Output is correct
3 Correct 160 ms 4944 KB Output is correct
4 Correct 204 ms 5296 KB Output is correct
5 Correct 187 ms 4260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 196 ms 12904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 230 ms 5552 KB Output is correct
2 Correct 217 ms 5456 KB Output is correct
3 Correct 200 ms 4888 KB Output is correct
4 Correct 300 ms 6696 KB Output is correct
5 Correct 228 ms 5056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 235 ms 15052 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 255 ms 6224 KB Output is correct
2 Correct 252 ms 6256 KB Output is correct
3 Correct 225 ms 6824 KB Output is correct
4 Correct 289 ms 7204 KB Output is correct
5 Correct 281 ms 6076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 275 ms 17304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 293 ms 7344 KB Output is correct
2 Correct 297 ms 6896 KB Output is correct
3 Correct 281 ms 7556 KB Output is correct
4 Correct 338 ms 8364 KB Output is correct
5 Correct 304 ms 6848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 339 ms 21396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 368 ms 8788 KB Output is correct
2 Correct 365 ms 8304 KB Output is correct
3 Correct 346 ms 9448 KB Output is correct
4 Correct 413 ms 456 KB Output is correct
5 Correct 384 ms 596 KB Output is correct