# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1098000 |
2024-10-08T19:25:35 Z |
0x34c |
Mobile (BOI12_mobile) |
C++17 |
|
1000 ms |
125488 KB |
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define endl '\n'
#define int ll
#define ld long double
#define pdd pair<ld, ld>
using namespace std;
int dist2(pii a, pii b)
{
return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
}
ld dist(pii a, ld x)
{
return sqrt((((ld)a.first) - x) * (((ld)a.first) - x) + (ld)(a.second * a.second));
}
const int INF = 1e9 + 1;
const int INF2 = 1e12;
ld eps = 1e-4;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int N, L;
cin >> N >> L;
vector<pii> inp(N);
map<int, int> closest;
for (int i = 0; i < N; i++)
{
int x, y;
cin >> x >> y;
inp[i] = {x, y};
if (!closest.count(x))
closest[x] = y;
else
closest[x] = (abs(closest[x]) > abs(y) ? y : closest[x]);
}
vector<pii> pts;
for (pii p : closest)
pts.push_back(p);
N = pts.size();
auto calc_bp = [&](int idx1, int idx2)
{
ld l = -INF, r = INF;
while ((r - l) > eps)
{
ld m = l + (r - l) / 2;
ld d1 = dist(pts[idx1], m), d2 = dist(pts[idx2], m);
if (d1 < d2)
l = m;
else
r = m;
}
return l + (r - l) / 2LL;
};
stack<int> stk;
stk.push(0);
vector<ld> dists, bps;
for (int i = 1; i < N; i++)
{
ld bp = calc_bp(stk.top(), i);
while (!bps.empty() && bps.back() > bp)
{
bps.pop_back();
stk.pop();
dists.pop_back();
bp = calc_bp(stk.top(), i);
}
bps.push_back(bp);
dists.push_back(dist(pts[i], bp));
stk.push(i);
}
ld mx_dist = 0;
for (int i = 0; i < bps.size(); i++)
{
if (bps[i] < 0 || bps[i] > L)
continue;
mx_dist = max(mx_dist, dists[i]);
}
ld mn_start = INF2, mn_end = INF2;
for (int i = 0; i < N; i++)
{
mn_start = min(mn_start, dist(pts[i], 0));
mn_end = min(mn_end, dist(pts[i], L));
}
mx_dist = max({mx_dist, mn_start, mn_end});
cout << setprecision(4) << fixed << mx_dist << endl;
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:92:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
92 | for (int i = 0; i < bps.size(); i++)
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
# |
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 |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
5 ms |
860 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
604 KB |
Output is correct |
2 |
Correct |
13 ms |
1124 KB |
Output is correct |
3 |
Correct |
2 ms |
760 KB |
Output is correct |
4 |
Correct |
15 ms |
1124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
856 KB |
Output is correct |
2 |
Correct |
13 ms |
1116 KB |
Output is correct |
3 |
Correct |
2 ms |
592 KB |
Output is correct |
4 |
Correct |
15 ms |
1028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
856 KB |
Output is correct |
2 |
Correct |
13 ms |
980 KB |
Output is correct |
3 |
Correct |
2 ms |
612 KB |
Output is correct |
4 |
Correct |
15 ms |
1116 KB |
Output is correct |
5 |
Correct |
3 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
198 ms |
8656 KB |
Output is correct |
2 |
Correct |
175 ms |
7312 KB |
Output is correct |
3 |
Correct |
154 ms |
6348 KB |
Output is correct |
4 |
Correct |
221 ms |
9668 KB |
Output is correct |
5 |
Correct |
7 ms |
1616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
2904 KB |
Output is correct |
2 |
Correct |
114 ms |
5580 KB |
Output is correct |
3 |
Correct |
209 ms |
9068 KB |
Output is correct |
4 |
Correct |
233 ms |
9932 KB |
Output is correct |
5 |
Correct |
257 ms |
10704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
151 ms |
14956 KB |
Output is correct |
2 |
Correct |
167 ms |
7072 KB |
Output is correct |
3 |
Correct |
138 ms |
13568 KB |
Output is correct |
4 |
Correct |
300 ms |
12236 KB |
Output is correct |
5 |
Correct |
71 ms |
4312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
7236 KB |
Output is correct |
2 |
Correct |
149 ms |
7116 KB |
Output is correct |
3 |
Correct |
53 ms |
4688 KB |
Output is correct |
4 |
Correct |
304 ms |
12304 KB |
Output is correct |
5 |
Correct |
248 ms |
10448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
223 ms |
14216 KB |
Output is correct |
2 |
Correct |
151 ms |
7112 KB |
Output is correct |
3 |
Correct |
55 ms |
4844 KB |
Output is correct |
4 |
Correct |
304 ms |
12228 KB |
Output is correct |
5 |
Correct |
257 ms |
10440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
873 ms |
74672 KB |
Output is correct |
2 |
Correct |
181 ms |
16724 KB |
Output is correct |
3 |
Correct |
173 ms |
16212 KB |
Output is correct |
4 |
Execution timed out |
1056 ms |
58524 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
194 ms |
17236 KB |
Output is correct |
2 |
Execution timed out |
1071 ms |
56516 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1060 ms |
104472 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
205 ms |
20304 KB |
Output is correct |
2 |
Execution timed out |
1050 ms |
73144 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1063 ms |
113852 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
221 ms |
23376 KB |
Output is correct |
2 |
Execution timed out |
1085 ms |
80340 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1049 ms |
122688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
241 ms |
26452 KB |
Output is correct |
2 |
Execution timed out |
1074 ms |
89200 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1045 ms |
125488 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
281 ms |
32932 KB |
Output is correct |
2 |
Execution timed out |
1059 ms |
107200 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |