# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
465494 |
2021-08-16T08:38:21 Z |
tphuc2908 |
Mobile (BOI12_mobile) |
C++14 |
|
670 ms |
32540 KB |
#include<bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define repi(i,x,y) for(int i = x; i >= y; --i)
#define ci(x) int x; cin>> x
#define TC(t) ci(t); while(t--)
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define cii(x, y) ci(x); ci(y)
typedef long long ll;
typedef vector<int> vi;
const int N = 1e6 + 5;
const int mod = 1e9+7;
const int inf = 1e9 + 5;
void readfile(){
#ifdef ONLINE_JUDGE
#else
freopen("text.inp", "r", stdin);
#endif // ONLINE_JUDGE
// freopen("angry.in", "r", stdin);
// freopen("angry.out", "w", stdout);
}
int n;
int L;
pair<double, double> a[N];
vector<pair<double, double> > store;
void inp(){
cin >> n >> L;
rep(i,1,n){
cii(x, y);
a[i] = {double(x), double(y)};
}
}
void trim(){
rep(i,1,n){
if(i==1 || a[i].fi != a[i-1].fi)
store.pb(a[i]);
}
}
void process(){
trim();
if((int)store.size()==1){
cout << max(sqrt((store[0].fi-L)*(store[0].fi-L) + store[0].se*store[0].se), sqrt(store[0].fi*store[0].fi + store[0].se*store[0].se));
return;
}
double res = 0;
if(0 <= a[0].fi)
res = sqrt(a[0].fi*a[0].fi + a[0].se*a[0].se);
rep(i,0,(int)store.size()-2){
double l = store[i].fi, r = store[i+1].fi;
rep(j,1,30){
double mid = (l + r) / 2;
double cal1 = sqrt((mid-store[i].fi)*(mid-store[i].fi) + store[i].se*store[i].se);
double cal2 = sqrt((mid-store[i+1].fi)*(mid-store[i+1].fi) + store[i+1].se*store[i+1].se);
res = max(res, min(cal1, cal2));
if(cal1 <= cal2)
l = mid;
else r = mid;
}
}
if(L >= store.back().fi)
res = max(res, sqrt((store.back().fi - L)*(store.back().fi - L) + store.back().se*store.back().se));
cout << fixed << setprecision(3) << res;
}
int main(){
//readfile();
ios_base::sync_with_stdio(0);
cin.tie(0);
inp();
process();
return 0;
}
Compilation message
mobile.cpp: In function 'void readfile()':
mobile.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | freopen("text.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
3768 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
1824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
3912 KB |
Output is correct |
2 |
Incorrect |
46 ms |
2824 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
3124 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
4160 KB |
Output is correct |
2 |
Incorrect |
45 ms |
4412 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
342 ms |
16516 KB |
Output is correct |
2 |
Incorrect |
128 ms |
16212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
132 ms |
8580 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
411 ms |
26388 KB |
Output is correct |
2 |
Incorrect |
162 ms |
19176 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
166 ms |
10020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
478 ms |
27916 KB |
Output is correct |
2 |
Incorrect |
200 ms |
22328 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
198 ms |
11568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
538 ms |
29420 KB |
Output is correct |
2 |
Incorrect |
238 ms |
25412 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
198 ms |
13156 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
670 ms |
32540 KB |
Output is correct |
2 |
Incorrect |
259 ms |
31556 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
244 ms |
16144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |