# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
658005 |
2022-11-11T19:54:50 Z |
chjiao |
Mobile (BOI12_mobile) |
C++14 |
|
894 ms |
32332 KB |
//Binary search the shortest length from the firehose
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORB(i,a,b) for(ll i=a;i>=b;i--)
#define getbit(mask,i) ((mask>>(i))&1)
#define getnum(i) (1<<(i))
#define endl "\n"
#define sz(x) (int)size(x)
#define mp make_pair
using ll = long long;
const ll MOD1 = 1e9+7;
const ll MOD2 = 998244353;
const ll MN = 1e5;
const ll MAX = LLONG_MAX;
long double FLOAT_ERR = 1e-7;
long double first_true_float(long double lo, long double hi, function<bool(long double)> f) {
// if none of the values in the range work, return hi + 1
lo--;
hi++;
while (hi-lo > FLOAT_ERR) {
long double mid = (lo + hi) / 2.0f;
if (f(mid)) {
hi = mid;
} else {
lo = mid;
}
}
return lo;
}
int main() {
fastio;
//freopen("x.in","r",stdin);
// freopen("XXX.out","w",stdout);
int N;
long double L;
cin >> N >> L;
vector<pair<long double,long double>> input(N);
for(int i=0; i<N; i++){
cin >> input[i].first >> input[i].second;
}
cout <<fixed << setprecision(7)<<first_true_float(1, 1.5e9+1, [&](long double x){
long double left = 0;
FOR(i,0,N-1){
if(x*x < input[i].second*input[i].second){
continue;
}
long double diviation = sqrt(x*x - input[i].second*input[i].second);
if((input[i].first-diviation) <= left){
left = max(input[i].first+diviation,left);
}
}
if(left >= L){
return true;
} else{
return false;
}
}) << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
436 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
460 KB |
Output is correct |
2 |
Correct |
4 ms |
468 KB |
Output is correct |
3 |
Correct |
4 ms |
464 KB |
Output is correct |
4 |
Correct |
4 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
468 KB |
Output is correct |
2 |
Correct |
6 ms |
468 KB |
Output is correct |
3 |
Correct |
4 ms |
468 KB |
Output is correct |
4 |
Correct |
4 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
468 KB |
Output is correct |
2 |
Correct |
4 ms |
468 KB |
Output is correct |
3 |
Correct |
4 ms |
460 KB |
Output is correct |
4 |
Correct |
4 ms |
468 KB |
Output is correct |
5 |
Correct |
4 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
3404 KB |
Output is correct |
2 |
Correct |
62 ms |
3740 KB |
Output is correct |
3 |
Correct |
40 ms |
2520 KB |
Output is correct |
4 |
Correct |
56 ms |
3660 KB |
Output is correct |
5 |
Correct |
32 ms |
2260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
65 ms |
3416 KB |
Output is correct |
2 |
Correct |
46 ms |
3284 KB |
Output is correct |
3 |
Correct |
54 ms |
3788 KB |
Output is correct |
4 |
Correct |
58 ms |
3792 KB |
Output is correct |
5 |
Correct |
66 ms |
4012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
3712 KB |
Output is correct |
2 |
Correct |
70 ms |
3832 KB |
Output is correct |
3 |
Correct |
60 ms |
3860 KB |
Output is correct |
4 |
Correct |
77 ms |
4456 KB |
Output is correct |
5 |
Correct |
62 ms |
4004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
4476 KB |
Output is correct |
2 |
Correct |
86 ms |
4456 KB |
Output is correct |
3 |
Correct |
74 ms |
4480 KB |
Output is correct |
4 |
Correct |
74 ms |
4452 KB |
Output is correct |
5 |
Correct |
73 ms |
4412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
4372 KB |
Output is correct |
2 |
Correct |
81 ms |
4348 KB |
Output is correct |
3 |
Correct |
69 ms |
4468 KB |
Output is correct |
4 |
Correct |
80 ms |
4460 KB |
Output is correct |
5 |
Correct |
72 ms |
4468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
387 ms |
16880 KB |
Output is correct |
2 |
Correct |
410 ms |
16976 KB |
Output is correct |
3 |
Correct |
391 ms |
16992 KB |
Output is correct |
4 |
Correct |
398 ms |
17004 KB |
Output is correct |
5 |
Correct |
349 ms |
16972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
411 ms |
16972 KB |
Output is correct |
2 |
Correct |
480 ms |
17012 KB |
Output is correct |
3 |
Correct |
352 ms |
16912 KB |
Output is correct |
4 |
Correct |
366 ms |
16992 KB |
Output is correct |
5 |
Correct |
346 ms |
17084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
457 ms |
20124 KB |
Output is correct |
2 |
Correct |
476 ms |
20004 KB |
Output is correct |
3 |
Correct |
541 ms |
20044 KB |
Output is correct |
4 |
Correct |
459 ms |
20108 KB |
Output is correct |
5 |
Correct |
422 ms |
20172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
487 ms |
20116 KB |
Output is correct |
2 |
Correct |
570 ms |
20056 KB |
Output is correct |
3 |
Correct |
424 ms |
20164 KB |
Output is correct |
4 |
Correct |
454 ms |
20092 KB |
Output is correct |
5 |
Correct |
420 ms |
20044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
540 ms |
23244 KB |
Output is correct |
2 |
Correct |
560 ms |
23184 KB |
Output is correct |
3 |
Correct |
563 ms |
23124 KB |
Output is correct |
4 |
Correct |
546 ms |
23116 KB |
Output is correct |
5 |
Correct |
486 ms |
23096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
588 ms |
23064 KB |
Output is correct |
2 |
Correct |
647 ms |
23008 KB |
Output is correct |
3 |
Correct |
504 ms |
22980 KB |
Output is correct |
4 |
Correct |
528 ms |
23004 KB |
Output is correct |
5 |
Correct |
484 ms |
22988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
604 ms |
26176 KB |
Output is correct |
2 |
Correct |
689 ms |
26084 KB |
Output is correct |
3 |
Correct |
682 ms |
25980 KB |
Output is correct |
4 |
Correct |
606 ms |
25996 KB |
Output is correct |
5 |
Correct |
551 ms |
25932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
653 ms |
26348 KB |
Output is correct |
2 |
Correct |
730 ms |
25796 KB |
Output is correct |
3 |
Correct |
606 ms |
25868 KB |
Output is correct |
4 |
Correct |
619 ms |
25812 KB |
Output is correct |
5 |
Correct |
562 ms |
25804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
731 ms |
32332 KB |
Output is correct |
2 |
Correct |
800 ms |
31972 KB |
Output is correct |
3 |
Correct |
778 ms |
31936 KB |
Output is correct |
4 |
Correct |
740 ms |
32076 KB |
Output is correct |
5 |
Correct |
691 ms |
31948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
805 ms |
31656 KB |
Output is correct |
2 |
Correct |
894 ms |
31968 KB |
Output is correct |
3 |
Correct |
751 ms |
31820 KB |
Output is correct |
4 |
Correct |
764 ms |
31852 KB |
Output is correct |
5 |
Correct |
691 ms |
31876 KB |
Output is correct |