Submission #554950

# Submission time Handle Problem Language Result Execution time Memory
554950 2022-04-29T17:57:42 Z victor_gao Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 78704 KB
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define double long double
#define pii pair<int,int>
#define x first
#define y second
#define N 1000015
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int n,L;
pii arr[N];
map<int,int>mp;
bool check(double val){
	//cout<<sqrt(val)<<" -> \n";
	double l=0,r=-1;
	for (int i=1;i<=n;i++){
		if (val*val-arr[i].y*arr[i].y<=0.000001) continue;
		double dl=(double)arr[i].x-sqrt(val*val-arr[i].y*arr[i].y);
		double dr=(double)arr[i].x+sqrt(val*val-arr[i].y*arr[i].y);
		if (l<r){
			if (dl-r>0.000001){
				l=dl;
			}
			else {
				r=max(r,dr);
				l=min(l,dl);
			}
		}
		else {
			if (r-dl>0.000001){
				r=dr;
				l=dl;
			}
		}
//		cout<<l<<" "<<r<<'\n';
	}
	if (r>=L){
	//	cout<<"OK\n";
		return 1;
	}
//	cout<<"NO\n";
	return 0;
}
bool cmp(pii a,pii b){
	if (a.x!=b.x) return a.x<b.x;
	else return a.y>b.y;
} 
signed main(){
	fast
//	freopen("loan.in","r",stdin);
//	freopen("loan.out","w",stdout);
	cout<<fixed<<setprecision(5);
	cin>>n>>L;
	for (int i=1;i<=n;i++){
		cin>>arr[i].x>>arr[i].y;
		if (!mp[arr[i].x]) mp[arr[i].x]=arr[i].y;
		else mp[arr[i].x]=min(arr[i].y,mp[arr[i].x]);
	}
	n=0;
	for (auto i:mp)	arr[++n]=i;
	double l=0,r=4e18;
	while (r-l>0.00001){
		double mid=(l+r)/2.0;
	//	cout<<l<<" ~ "<<r<<'\n';
		if (check(mid)) r=mid;
		else l=mid;
	}
	cout<<(double)(l)<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 596 KB Output is correct
2 Incorrect 7 ms 724 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 95 ms 7212 KB Output is correct
2 Incorrect 74 ms 4940 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 4496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 118 ms 8144 KB Output is correct
2 Incorrect 77 ms 4556 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 564 ms 39508 KB Output is correct
2 Incorrect 185 ms 8776 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 185 ms 8780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 695 ms 47316 KB Output is correct
2 Incorrect 215 ms 10188 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 215 ms 10144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 792 ms 55148 KB Output is correct
2 Incorrect 243 ms 11852 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 251 ms 11572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 909 ms 62944 KB Output is correct
2 Incorrect 264 ms 13328 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 284 ms 13212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 78704 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 333 ms 16172 KB Output isn't correct
2 Halted 0 ms 0 KB -