Submission #864761

# Submission time Handle Problem Language Result Execution time Memory
864761 2023-10-23T14:42:48 Z nhatvpm Mobile (BOI12_mobile) C++17
100 / 100
565 ms 35048 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld=long double;

void setIO(string name) {
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

void solve(){
	ll n,l;
	cin>>n>>l;
	vector<ll> x(n),y(n);
	for (int i=0;i<n;i++) cin>>x[i]>>y[i];
	ld lo=0,hi=3e9,eps=1e-9;
	while (hi-lo>eps){
		ld mid=(lo+hi)/2,s=0;
		for (int i=0;i<n;i++){
			if (mid<abs(y[i])) continue;
			ld d=sqrt(pow(mid,2)-pow(y[i],2));
			ld a=x[i]-d,b=x[i]+d;
			if (a<=s) s=max(s,b);
		}
		if (s>=l) hi=mid;
		else lo=mid;
	}
	cout<<fixed<<setprecision(15)<<lo;
	
	
	
	
	
	
	
}


int main(){
	//setIO("");
	ios_base::sync_with_stdio(0);
    cin.tie(0);
	int tc=1;
	//cin>>tc;
	while (tc--){
		solve();
	}
}

Compilation message

mobile.cpp: In function 'void setIO(std::string)':
mobile.cpp:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:9:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 516 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 720 KB Output is correct
2 Correct 2 ms 472 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 464 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
5 Correct 2 ms 576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 2528 KB Output is correct
2 Correct 32 ms 2648 KB Output is correct
3 Correct 20 ms 1908 KB Output is correct
4 Correct 23 ms 2652 KB Output is correct
5 Correct 15 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2320 KB Output is correct
2 Correct 26 ms 2388 KB Output is correct
3 Correct 24 ms 2652 KB Output is correct
4 Correct 24 ms 2652 KB Output is correct
5 Correct 25 ms 3224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2392 KB Output is correct
2 Correct 35 ms 2904 KB Output is correct
3 Correct 32 ms 2652 KB Output is correct
4 Correct 29 ms 3972 KB Output is correct
5 Correct 27 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 3420 KB Output is correct
2 Correct 43 ms 3280 KB Output is correct
3 Correct 37 ms 2904 KB Output is correct
4 Correct 30 ms 3932 KB Output is correct
5 Correct 30 ms 3172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 3528 KB Output is correct
2 Correct 45 ms 3668 KB Output is correct
3 Correct 40 ms 2908 KB Output is correct
4 Correct 29 ms 3928 KB Output is correct
5 Correct 31 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 222 ms 12560 KB Output is correct
2 Correct 227 ms 15988 KB Output is correct
3 Correct 226 ms 15484 KB Output is correct
4 Correct 149 ms 17600 KB Output is correct
5 Correct 160 ms 15040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 217 ms 16476 KB Output is correct
2 Correct 324 ms 14672 KB Output is correct
3 Correct 181 ms 13912 KB Output is correct
4 Correct 136 ms 17352 KB Output is correct
5 Correct 140 ms 15444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 261 ms 15008 KB Output is correct
2 Correct 269 ms 19108 KB Output is correct
3 Correct 260 ms 18520 KB Output is correct
4 Correct 170 ms 21584 KB Output is correct
5 Correct 179 ms 17748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 258 ms 19524 KB Output is correct
2 Correct 373 ms 17752 KB Output is correct
3 Correct 232 ms 16496 KB Output is correct
4 Correct 175 ms 21556 KB Output is correct
5 Correct 183 ms 18524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 312 ms 17284 KB Output is correct
2 Correct 305 ms 22240 KB Output is correct
3 Correct 305 ms 21328 KB Output is correct
4 Correct 190 ms 24916 KB Output is correct
5 Correct 199 ms 20244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 310 ms 22864 KB Output is correct
2 Correct 422 ms 20820 KB Output is correct
3 Correct 251 ms 19536 KB Output is correct
4 Correct 194 ms 24916 KB Output is correct
5 Correct 195 ms 21536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 359 ms 20048 KB Output is correct
2 Correct 334 ms 25172 KB Output is correct
3 Correct 392 ms 24584 KB Output is correct
4 Correct 222 ms 28496 KB Output is correct
5 Correct 230 ms 24360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 345 ms 26012 KB Output is correct
2 Correct 461 ms 23528 KB Output is correct
3 Correct 316 ms 22356 KB Output is correct
4 Correct 219 ms 28316 KB Output is correct
5 Correct 230 ms 24352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 446 ms 24792 KB Output is correct
2 Correct 438 ms 31444 KB Output is correct
3 Correct 428 ms 30652 KB Output is correct
4 Correct 304 ms 35048 KB Output is correct
5 Correct 288 ms 29672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 434 ms 32356 KB Output is correct
2 Correct 565 ms 29304 KB Output is correct
3 Correct 367 ms 28384 KB Output is correct
4 Correct 276 ms 35040 KB Output is correct
5 Correct 282 ms 30680 KB Output is correct