# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
199188 |
2020-01-29T23:23:55 Z |
imaxblue |
Mobile (BOI12_mobile) |
C++17 |
|
398 ms |
40788 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vp3i vector<p3i>
#define vpll vector<pll>
#define vp3l vector<p3l>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846
#define startrng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long double ans;
int n, d, x, y;
vector<pll> v;
vector<pll> hull;
//f(x) = x^2 + mx + b
//xa1+b1=xa2+b2
//x=(b2-b1)/(a1-a2);
long double eval(pll A, long double X){
//cout << A.x << ' ' << A.y << ' ' << X << endl;
return sqrt(X*X+X*A.x+A.y);
}
void check(pll A, pll B){
long double x=(B.y-A.y)/((long double)(A.x-B.x));
if (x<0 || x>d) return;
ans = max(eval(A, x), ans);
}
bool cross(pll A, pll O, pll B){
return ((long double)(A.x-O.x))*(B.y-O.y)>=((long double)(A.y-O.y))*(B.x-O.x);//+(1e-9);
}
int32_t main(){
scanf("%i%i", &n, &d);
fox(l, n){
scanf("%i%i", &x, &y);
v.pb(mp(-2*x, 1LL*y*y+1LL*x*x));
}
sort(v.begin(), v.end());
for (auto i:v){
while(hull.size()>1 && cross(hull[hull.size()-2], hull.back(), i)){
hull.pop_back();
}
hull.pb(i);
}
fox(l, hull.size()-1){
check(hull[l], hull[l+1]);
}
//cout << hull.size() << endl;
//cout << ans << endl;
long double lft=(1LL<<62), rit=(1LL<<62);
fox(l, hull.size()){
lft=min(lft, eval(hull[l], 0));
rit=min(rit, eval(hull[l], d));
}
//cout << lft << ' ' << rit << endl;
ans = max(ans, max(lft, rit));
//cout << sqrt(ans) << endl;
printf("%.8Lf", ans);
return 0;
}
/*
3 10
0 0
5 1000000000
11 1
*/
Compilation message
mobile.cpp: In function 'int32_t main()':
mobile.cpp:23:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
mobile.cpp:68:7:
fox(l, hull.size()-1){
~~~~~~~~~~~~~~~~
mobile.cpp:68:3: note: in expansion of macro 'fox'
fox(l, hull.size()-1){
^~~
mobile.cpp:23:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
mobile.cpp:74:7:
fox(l, hull.size()){
~~~~~~~~~~~~~~
mobile.cpp:74:3: note: in expansion of macro 'fox'
fox(l, hull.size()){
^~~
mobile.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i%i", &n, &d);
~~~~~^~~~~~~~~~~~~~~~
mobile.cpp:58:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i%i", &x, &y);
~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
504 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
504 KB |
Output is correct |
2 |
Correct |
6 ms |
504 KB |
Output is correct |
3 |
Correct |
6 ms |
504 KB |
Output is correct |
4 |
Correct |
6 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
504 KB |
Output is correct |
2 |
Correct |
6 ms |
504 KB |
Output is correct |
3 |
Correct |
6 ms |
504 KB |
Output is correct |
4 |
Correct |
6 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
632 KB |
Output is correct |
2 |
Correct |
7 ms |
504 KB |
Output is correct |
3 |
Correct |
6 ms |
504 KB |
Output is correct |
4 |
Correct |
6 ms |
504 KB |
Output is correct |
5 |
Correct |
6 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
2540 KB |
Output is correct |
2 |
Correct |
30 ms |
2536 KB |
Output is correct |
3 |
Correct |
20 ms |
1520 KB |
Output is correct |
4 |
Correct |
32 ms |
2536 KB |
Output is correct |
5 |
Correct |
19 ms |
1520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
2536 KB |
Output is correct |
2 |
Correct |
27 ms |
2540 KB |
Output is correct |
3 |
Correct |
31 ms |
2536 KB |
Output is correct |
4 |
Correct |
33 ms |
2536 KB |
Output is correct |
5 |
Correct |
37 ms |
2540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
4708 KB |
Output is correct |
2 |
Correct |
40 ms |
2540 KB |
Output is correct |
3 |
Correct |
32 ms |
4708 KB |
Output is correct |
4 |
Correct |
46 ms |
2488 KB |
Output is correct |
5 |
Correct |
31 ms |
3436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
2540 KB |
Output is correct |
2 |
Correct |
40 ms |
2540 KB |
Output is correct |
3 |
Correct |
33 ms |
2536 KB |
Output is correct |
4 |
Correct |
48 ms |
2536 KB |
Output is correct |
5 |
Correct |
37 ms |
3560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
3816 KB |
Output is correct |
2 |
Correct |
36 ms |
2540 KB |
Output is correct |
3 |
Correct |
32 ms |
2540 KB |
Output is correct |
4 |
Correct |
45 ms |
2536 KB |
Output is correct |
5 |
Correct |
37 ms |
3560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
153 ms |
20560 KB |
Output is correct |
2 |
Correct |
169 ms |
8668 KB |
Output is correct |
3 |
Correct |
166 ms |
8668 KB |
Output is correct |
4 |
Correct |
203 ms |
8672 KB |
Output is correct |
5 |
Correct |
172 ms |
15056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
8796 KB |
Output is correct |
2 |
Correct |
160 ms |
10064 KB |
Output is correct |
3 |
Correct |
155 ms |
11648 KB |
Output is correct |
4 |
Correct |
198 ms |
8668 KB |
Output is correct |
5 |
Correct |
173 ms |
15568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
189 ms |
34364 KB |
Output is correct |
2 |
Correct |
222 ms |
16856 KB |
Output is correct |
3 |
Correct |
203 ms |
16848 KB |
Output is correct |
4 |
Correct |
252 ms |
17028 KB |
Output is correct |
5 |
Correct |
211 ms |
24016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
216 ms |
16844 KB |
Output is correct |
2 |
Correct |
195 ms |
16848 KB |
Output is correct |
3 |
Correct |
189 ms |
16848 KB |
Output is correct |
4 |
Correct |
246 ms |
16852 KB |
Output is correct |
5 |
Correct |
210 ms |
24656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
216 ms |
36028 KB |
Output is correct |
2 |
Correct |
253 ms |
16848 KB |
Output is correct |
3 |
Correct |
247 ms |
16848 KB |
Output is correct |
4 |
Correct |
282 ms |
16848 KB |
Output is correct |
5 |
Correct |
234 ms |
23764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
256 ms |
16848 KB |
Output is correct |
2 |
Correct |
224 ms |
16860 KB |
Output is correct |
3 |
Correct |
208 ms |
16848 KB |
Output is correct |
4 |
Correct |
278 ms |
16848 KB |
Output is correct |
5 |
Correct |
247 ms |
24800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
243 ms |
37660 KB |
Output is correct |
2 |
Correct |
285 ms |
16848 KB |
Output is correct |
3 |
Correct |
278 ms |
16844 KB |
Output is correct |
4 |
Correct |
321 ms |
16848 KB |
Output is correct |
5 |
Correct |
280 ms |
24404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
288 ms |
16848 KB |
Output is correct |
2 |
Correct |
266 ms |
16984 KB |
Output is correct |
3 |
Correct |
242 ms |
16848 KB |
Output is correct |
4 |
Correct |
318 ms |
16852 KB |
Output is correct |
5 |
Correct |
276 ms |
24656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
297 ms |
40788 KB |
Output is correct |
2 |
Correct |
345 ms |
16848 KB |
Output is correct |
3 |
Correct |
345 ms |
16852 KB |
Output is correct |
4 |
Correct |
395 ms |
16848 KB |
Output is correct |
5 |
Correct |
345 ms |
29752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
348 ms |
16848 KB |
Output is correct |
2 |
Correct |
319 ms |
19132 KB |
Output is correct |
3 |
Correct |
301 ms |
22564 KB |
Output is correct |
4 |
Correct |
398 ms |
17040 KB |
Output is correct |
5 |
Correct |
354 ms |
30912 KB |
Output is correct |