# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
972684 |
2024-04-30T21:32:35 Z |
iag99 |
Mobile (BOI12_mobile) |
C++17 |
|
419 ms |
25520 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;
}
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};
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
452 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
344 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 |
# |
Verdict |
Execution time |
Memory |
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 |
4 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
1368 KB |
Output is correct |
2 |
Correct |
27 ms |
1340 KB |
Output is correct |
3 |
Correct |
17 ms |
856 KB |
Output is correct |
4 |
Correct |
29 ms |
1468 KB |
Output is correct |
5 |
Correct |
15 ms |
856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1116 KB |
Output is correct |
2 |
Correct |
24 ms |
1088 KB |
Output is correct |
3 |
Correct |
30 ms |
1340 KB |
Output is correct |
4 |
Correct |
31 ms |
1616 KB |
Output is correct |
5 |
Correct |
34 ms |
1884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
2388 KB |
Output is correct |
2 |
Correct |
34 ms |
1728 KB |
Output is correct |
3 |
Correct |
28 ms |
2392 KB |
Output is correct |
4 |
Correct |
43 ms |
2220 KB |
Output is correct |
5 |
Correct |
36 ms |
1228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
1848 KB |
Output is correct |
2 |
Correct |
33 ms |
1628 KB |
Output is correct |
3 |
Correct |
30 ms |
1624 KB |
Output is correct |
4 |
Correct |
43 ms |
2340 KB |
Output is correct |
5 |
Correct |
35 ms |
1624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
2764 KB |
Output is correct |
2 |
Correct |
36 ms |
1624 KB |
Output is correct |
3 |
Correct |
30 ms |
1624 KB |
Output is correct |
4 |
Correct |
41 ms |
2384 KB |
Output is correct |
5 |
Correct |
35 ms |
1616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
155 ms |
12772 KB |
Output is correct |
2 |
Correct |
167 ms |
8020 KB |
Output is correct |
3 |
Correct |
164 ms |
7660 KB |
Output is correct |
4 |
Correct |
209 ms |
9780 KB |
Output is correct |
5 |
Correct |
183 ms |
7212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
8884 KB |
Output is correct |
2 |
Correct |
172 ms |
7764 KB |
Output is correct |
3 |
Correct |
154 ms |
7600 KB |
Output is correct |
4 |
Correct |
198 ms |
9556 KB |
Output is correct |
5 |
Correct |
182 ms |
7504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
186 ms |
15476 KB |
Output is correct |
2 |
Correct |
202 ms |
9632 KB |
Output is correct |
3 |
Correct |
196 ms |
9132 KB |
Output is correct |
4 |
Correct |
244 ms |
12116 KB |
Output is correct |
5 |
Correct |
213 ms |
8532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
207 ms |
10288 KB |
Output is correct |
2 |
Correct |
214 ms |
9136 KB |
Output is correct |
3 |
Correct |
192 ms |
8352 KB |
Output is correct |
4 |
Correct |
251 ms |
12116 KB |
Output is correct |
5 |
Correct |
222 ms |
9016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
225 ms |
17852 KB |
Output is correct |
2 |
Correct |
232 ms |
11092 KB |
Output is correct |
3 |
Correct |
237 ms |
10956 KB |
Output is correct |
4 |
Correct |
283 ms |
13904 KB |
Output is correct |
5 |
Correct |
244 ms |
9256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
238 ms |
12112 KB |
Output is correct |
2 |
Correct |
238 ms |
10560 KB |
Output is correct |
3 |
Correct |
218 ms |
10908 KB |
Output is correct |
4 |
Correct |
288 ms |
13616 KB |
Output is correct |
5 |
Correct |
257 ms |
10532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
260 ms |
20424 KB |
Output is correct |
2 |
Correct |
265 ms |
12628 KB |
Output is correct |
3 |
Correct |
267 ms |
11960 KB |
Output is correct |
4 |
Correct |
329 ms |
15956 KB |
Output is correct |
5 |
Correct |
330 ms |
11476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
296 ms |
13604 KB |
Output is correct |
2 |
Correct |
278 ms |
11992 KB |
Output is correct |
3 |
Correct |
253 ms |
11836 KB |
Output is correct |
4 |
Correct |
351 ms |
15700 KB |
Output is correct |
5 |
Correct |
297 ms |
11952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
328 ms |
25520 KB |
Output is correct |
2 |
Correct |
337 ms |
15792 KB |
Output is correct |
3 |
Correct |
345 ms |
14976 KB |
Output is correct |
4 |
Correct |
417 ms |
19512 KB |
Output is correct |
5 |
Correct |
391 ms |
14124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
358 ms |
16828 KB |
Output is correct |
2 |
Correct |
347 ms |
14956 KB |
Output is correct |
3 |
Correct |
322 ms |
15052 KB |
Output is correct |
4 |
Correct |
419 ms |
19768 KB |
Output is correct |
5 |
Correct |
383 ms |
15148 KB |
Output is correct |