# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
133182 |
2019-07-20T08:46:32 Z |
win11905 |
Mobile (BOI12_mobile) |
C++11 |
|
380 ms |
18512 KB |
#include <bits/stdc++.h>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
int n, k;
vector<pii> vec;
double dist(pii p, double x) {
return hypot((double)p.x - x, (double)p.y);
}
double f(double x) { return x * x; }
double getx(pii p1, pii p2) {
double x1 = p1.x, x2 = p2.x, y1 = p1.y, y2 = p2.y;
return (f(x2) + f(y2) - f(x1) - f(y1)) / (2 * (x2 - x1));
}
int main() {
scanf("%d %d", &n, &k);
for(int i = 0, x, y; i < n; ++i) {
scanf("%d %d", &x, &y);
if(vec.empty()) vec.emplace_back(x, abs(y));
else if(vec.back().x == x) vec.back().y = min(vec.back().y, abs(y));
else vec.emplace_back(x, abs(y));
}
deque<pii> stk;
stk.emplace_back(vec[0]), stk.emplace_back(vec[1]);
for(int i = 2; i < vec.size(); ++i) {
while(stk.size() >= 2 && getx(stk.back(), vec[i]) <= getx(stk[stk.size()-2], vec[i])) stk.pop_back();
stk.emplace_back(vec[i]);
}
while(stk.size() >= 2 && getx(stk[0], stk[1]) < 0) stk.pop_front();
while(stk.size() >= 2 && getx(stk[stk.size()-2], stk.back()) > k) stk.pop_back();
double ans = 0;
ans = max(ans, dist(stk[0], 0));
ans = max(ans, dist(stk.back(), k));
for(int i = 1; i < stk.size(); ++i) {
double x = getx(stk[i], stk[i-1]);
ans = max(ans, dist(stk[i], x));
}
printf("%.6f\n", ans);
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:31:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 2; i < vec.size(); ++i) {
~~^~~~~~~~~~~~
mobile.cpp:40:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1; i < stk.size(); ++i) {
~~^~~~~~~~~~~~
mobile.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &n, &k);
~~~~~^~~~~~~~~~~~~~~~~
mobile.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &x, &y);
~~~~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
2160 KB |
Output is correct |
2 |
Correct |
26 ms |
1776 KB |
Output is correct |
3 |
Correct |
16 ms |
1524 KB |
Output is correct |
4 |
Correct |
29 ms |
2472 KB |
Output is correct |
5 |
Correct |
12 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
1096 KB |
Output is correct |
2 |
Correct |
23 ms |
1780 KB |
Output is correct |
3 |
Correct |
28 ms |
2288 KB |
Output is correct |
4 |
Correct |
31 ms |
2288 KB |
Output is correct |
5 |
Correct |
34 ms |
2288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
2408 KB |
Output is correct |
2 |
Correct |
25 ms |
1780 KB |
Output is correct |
3 |
Correct |
25 ms |
2292 KB |
Output is correct |
4 |
Correct |
41 ms |
2796 KB |
Output is correct |
5 |
Correct |
23 ms |
1528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1776 KB |
Output is correct |
2 |
Correct |
29 ms |
2160 KB |
Output is correct |
3 |
Correct |
23 ms |
1400 KB |
Output is correct |
4 |
Correct |
41 ms |
2288 KB |
Output is correct |
5 |
Correct |
32 ms |
2416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
2668 KB |
Output is correct |
2 |
Correct |
29 ms |
2036 KB |
Output is correct |
3 |
Correct |
23 ms |
1400 KB |
Output is correct |
4 |
Correct |
41 ms |
2304 KB |
Output is correct |
5 |
Correct |
32 ms |
2416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
129 ms |
10500 KB |
Output is correct |
2 |
Correct |
127 ms |
2424 KB |
Output is correct |
3 |
Correct |
122 ms |
1936 KB |
Output is correct |
4 |
Correct |
192 ms |
6124 KB |
Output is correct |
5 |
Correct |
152 ms |
5476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
2680 KB |
Output is correct |
2 |
Correct |
148 ms |
6028 KB |
Output is correct |
3 |
Correct |
114 ms |
3364 KB |
Output is correct |
4 |
Correct |
187 ms |
5484 KB |
Output is correct |
5 |
Correct |
161 ms |
5476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
159 ms |
12292 KB |
Output is correct |
2 |
Correct |
152 ms |
2708 KB |
Output is correct |
3 |
Correct |
149 ms |
1244 KB |
Output is correct |
4 |
Correct |
236 ms |
9436 KB |
Output is correct |
5 |
Correct |
203 ms |
5476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
2768 KB |
Output is correct |
2 |
Correct |
181 ms |
10188 KB |
Output is correct |
3 |
Correct |
136 ms |
3096 KB |
Output is correct |
4 |
Correct |
238 ms |
9512 KB |
Output is correct |
5 |
Correct |
195 ms |
9668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
13648 KB |
Output is correct |
2 |
Correct |
183 ms |
2532 KB |
Output is correct |
3 |
Correct |
172 ms |
1272 KB |
Output is correct |
4 |
Correct |
268 ms |
9404 KB |
Output is correct |
5 |
Correct |
192 ms |
5480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
180 ms |
2628 KB |
Output is correct |
2 |
Correct |
208 ms |
10060 KB |
Output is correct |
3 |
Correct |
159 ms |
3920 KB |
Output is correct |
4 |
Correct |
264 ms |
9452 KB |
Output is correct |
5 |
Correct |
223 ms |
9564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
208 ms |
15520 KB |
Output is correct |
2 |
Correct |
202 ms |
2596 KB |
Output is correct |
3 |
Correct |
196 ms |
1296 KB |
Output is correct |
4 |
Correct |
309 ms |
9628 KB |
Output is correct |
5 |
Correct |
239 ms |
5448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
205 ms |
2580 KB |
Output is correct |
2 |
Correct |
241 ms |
10204 KB |
Output is correct |
3 |
Correct |
178 ms |
3820 KB |
Output is correct |
4 |
Correct |
329 ms |
9404 KB |
Output is correct |
5 |
Correct |
257 ms |
9564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
257 ms |
18512 KB |
Output is correct |
2 |
Correct |
250 ms |
2552 KB |
Output is correct |
3 |
Correct |
247 ms |
1272 KB |
Output is correct |
4 |
Correct |
372 ms |
8668 KB |
Output is correct |
5 |
Correct |
284 ms |
5532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
254 ms |
1272 KB |
Output is correct |
2 |
Correct |
306 ms |
10016 KB |
Output is correct |
3 |
Correct |
226 ms |
4464 KB |
Output is correct |
4 |
Correct |
380 ms |
8848 KB |
Output is correct |
5 |
Correct |
316 ms |
9612 KB |
Output is correct |