#include <bits/stdc++.h>
//#include "cave.h"
using namespace std;
using tint = long long;
using ld = long double;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
using pi = pair<tint,int>;
using pl = pair<tint,tint>;
using vi = vector<int>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vvi = vector<vi>;
using vl = vector<tint>;
using vb = vector<bool>;
#define pb push_back
#define pf push_front
#define rsz resize
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)(x).size()
#define ins insert
#define f first
#define s second
#define mp make_pair
#define DBG(x) cerr << #x << " = " << x << endl;
const int MOD = 1e9+7;
const tint mod = 998244353;
const int MX = 515;
const tint INF = 1e18;
const int inf = 2e9;
const ld PI = acos(ld(-1));
const ld eps = 1e-8;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
template<class T> void remDup(vector<T> &v){
sort(all(v)); v.erase(unique(all(v)),end(v));
}
template<class T> bool ckmin(T& a, const T& b) {
return b < a ? a = b, 1 : 0;
}
template<class T> bool ckmax(T& a, const T& b) {
return a < b ? a = b, 1 : 0;
}
bool valid(int x, int y, int n, int m){
return (0<=x && x<n && 0<=y && y<m);
}
int cdiv(int a, int b) { return a/b+((a^b)>0&&a%b); } //redondea p arriba
int fdiv(int a, int b) { return a/b-((a^b)<0&&a%b); } //redondea p abajo
void NACHO(string name = ""){
ios_base::sync_with_stdio(0); cin.tie(0);
if(sz(name)){
freopen((name+".in").c_str(), "r", stdin);
freopen((name+".out").c_str(), "w", stdout);
}
}
int main(){
NACHO();
int n; tint l; cin >> n >> l;
vpl a (n);
F0R(i, n) cin >> a[i].f >> a[i].s;
double low = -1, high = double(5e9);
F0R(assa, 100){
double mid = low+(high-low)/2;
vector<pair<double, double>> ran (n);
F0R(i, n){
// mid*mid = p.y*p.y+x*x
double dist = sqrt(mid*mid-a[i].s*a[i].s);
ran[i] = mp(a[i].f-dist, a[i].f+dist);
}
double ri = 0;
F0R(i, n){
if(ran[i].f <= ri) ri = max(ri, ran[i].s);
}
if(ri >= l) high = mid;
else low = mid;
}
cout << fixed << setprecision(4) << high << "\n";
}
Compilation message
mobile.cpp: In function 'void NACHO(std::string)':
mobile.cpp:70:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
70 | freopen((name+".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:71:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
71 | freopen((name+".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
364 KB |
Output is correct |
2 |
Correct |
3 ms |
364 KB |
Output is correct |
3 |
Correct |
3 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
620 KB |
Output is correct |
2 |
Correct |
5 ms |
492 KB |
Output is correct |
3 |
Correct |
5 ms |
492 KB |
Output is correct |
4 |
Correct |
8 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
492 KB |
Output is correct |
2 |
Correct |
5 ms |
492 KB |
Output is correct |
3 |
Correct |
5 ms |
492 KB |
Output is correct |
4 |
Correct |
6 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
492 KB |
Output is correct |
2 |
Correct |
5 ms |
492 KB |
Output is correct |
3 |
Correct |
5 ms |
492 KB |
Output is correct |
4 |
Correct |
7 ms |
492 KB |
Output is correct |
5 |
Correct |
6 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
2668 KB |
Output is correct |
2 |
Correct |
73 ms |
2748 KB |
Output is correct |
3 |
Correct |
47 ms |
2028 KB |
Output is correct |
4 |
Correct |
90 ms |
2668 KB |
Output is correct |
5 |
Correct |
53 ms |
1900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
2796 KB |
Output is correct |
2 |
Correct |
81 ms |
2588 KB |
Output is correct |
3 |
Correct |
92 ms |
2932 KB |
Output is correct |
4 |
Correct |
97 ms |
2836 KB |
Output is correct |
5 |
Correct |
117 ms |
3104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
3084 KB |
Output is correct |
2 |
Correct |
69 ms |
2924 KB |
Output is correct |
3 |
Correct |
77 ms |
3008 KB |
Output is correct |
4 |
Correct |
127 ms |
3436 KB |
Output is correct |
5 |
Correct |
106 ms |
3068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
3436 KB |
Output is correct |
2 |
Correct |
92 ms |
3564 KB |
Output is correct |
3 |
Correct |
94 ms |
3436 KB |
Output is correct |
4 |
Correct |
125 ms |
3436 KB |
Output is correct |
5 |
Correct |
114 ms |
3436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
3436 KB |
Output is correct |
2 |
Correct |
85 ms |
3436 KB |
Output is correct |
3 |
Correct |
92 ms |
3436 KB |
Output is correct |
4 |
Correct |
125 ms |
3436 KB |
Output is correct |
5 |
Correct |
118 ms |
3436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
467 ms |
15980 KB |
Output is correct |
2 |
Correct |
495 ms |
16108 KB |
Output is correct |
3 |
Correct |
484 ms |
15980 KB |
Output is correct |
4 |
Correct |
705 ms |
15980 KB |
Output is correct |
5 |
Correct |
642 ms |
15980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
498 ms |
15980 KB |
Output is correct |
2 |
Correct |
932 ms |
16108 KB |
Output is correct |
3 |
Correct |
505 ms |
15980 KB |
Output is correct |
4 |
Correct |
659 ms |
16128 KB |
Output is correct |
5 |
Correct |
643 ms |
15980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
566 ms |
19148 KB |
Output is correct |
2 |
Correct |
586 ms |
19148 KB |
Output is correct |
3 |
Correct |
588 ms |
19148 KB |
Output is correct |
4 |
Correct |
807 ms |
19180 KB |
Output is correct |
5 |
Correct |
755 ms |
19180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
608 ms |
19180 KB |
Output is correct |
2 |
Execution timed out |
1064 ms |
19180 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
669 ms |
22320 KB |
Output is correct |
2 |
Correct |
704 ms |
22320 KB |
Output is correct |
3 |
Correct |
683 ms |
22380 KB |
Output is correct |
4 |
Correct |
936 ms |
22320 KB |
Output is correct |
5 |
Correct |
886 ms |
22320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
709 ms |
22320 KB |
Output is correct |
2 |
Execution timed out |
1082 ms |
22320 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
749 ms |
25364 KB |
Output is correct |
2 |
Correct |
795 ms |
25364 KB |
Output is correct |
3 |
Correct |
786 ms |
25364 KB |
Output is correct |
4 |
Execution timed out |
1065 ms |
25364 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
806 ms |
25492 KB |
Output is correct |
2 |
Execution timed out |
1093 ms |
25624 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
945 ms |
31712 KB |
Output is correct |
2 |
Execution timed out |
1012 ms |
31724 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1020 ms |
31724 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |