# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
465495 |
2021-08-16T08:45:38 Z |
tphuc2908 |
Mobile (BOI12_mobile) |
C++14 |
|
666 ms |
32452 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;
double 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 |
0 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 |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 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 |
3588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
1644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
3824 KB |
Output is correct |
2 |
Incorrect |
47 ms |
2756 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
2984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
3976 KB |
Output is correct |
2 |
Incorrect |
45 ms |
3012 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
341 ms |
16488 KB |
Output is correct |
2 |
Incorrect |
130 ms |
8520 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
126 ms |
8416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
410 ms |
26164 KB |
Output is correct |
2 |
Incorrect |
165 ms |
9848 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
152 ms |
9924 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
494 ms |
27812 KB |
Output is correct |
2 |
Incorrect |
168 ms |
11460 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
191 ms |
11460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
539 ms |
29388 KB |
Output is correct |
2 |
Incorrect |
196 ms |
13036 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
200 ms |
13156 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
666 ms |
32452 KB |
Output is correct |
2 |
Incorrect |
300 ms |
16104 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
253 ms |
16044 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |