Submission #417883

# Submission time Handle Problem Language Result Execution time Memory
417883 2021-06-04T12:55:21 Z jackkkk Mobile (BOI12_mobile) C++11
100 / 100
898 ms 35404 KB
#include <stdio.h>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <array>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <list>
#include <float.h>
#include <climits>
using namespace std;

void quit(){
    cout.flush();
    exit(0);
}

int n, l;
vector <pair<double, double>> towers;
bool good(double dist){
    //get_intervals
	double max_good = 0;
    for(const auto &tower : towers){
        if(abs(tower.second)>=dist){
            continue;
        }
        double range = sqrt((dist*dist)-(tower.second*tower.second));
        double left = tower.first-range;
		double right = tower.first+range;
		if(max_good<left){
			continue;
		}
		max_good=max(max_good, right);
    }
	return max_good>=l;
}
int main() {
	//freopen("qwer.in", "r", stdin);
	//freopen("qwer.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> l;
	towers.resize(n);
	for(int i = 0; i < n; i++){
	    cin >> towers[i].first >> towers[i].second;
	}
	
	double s = 0, e = 3*1e10, mid;
    while(e-s>0.0005){
        mid = (s+e)/2;
        if(good(mid)){
            e=mid;
        }
        else{
            s=mid;
        }
    }
    cout << fixed << setprecision(10) <<e << "\n";
	
	
	quit();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 320 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 432 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 4 ms 432 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 2240 KB Output is correct
2 Correct 70 ms 2696 KB Output is correct
3 Correct 39 ms 1740 KB Output is correct
4 Correct 56 ms 2632 KB Output is correct
5 Correct 32 ms 1480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 2284 KB Output is correct
2 Correct 50 ms 2232 KB Output is correct
3 Correct 60 ms 2580 KB Output is correct
4 Correct 59 ms 2696 KB Output is correct
5 Correct 82 ms 3012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 2304 KB Output is correct
2 Correct 67 ms 2728 KB Output is correct
3 Correct 70 ms 2596 KB Output is correct
4 Correct 82 ms 3768 KB Output is correct
5 Correct 58 ms 2592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 3396 KB Output is correct
2 Correct 79 ms 3264 KB Output is correct
3 Correct 71 ms 2876 KB Output is correct
4 Correct 81 ms 3788 KB Output is correct
5 Correct 87 ms 3016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 3404 KB Output is correct
2 Correct 80 ms 3264 KB Output is correct
3 Correct 71 ms 2896 KB Output is correct
4 Correct 88 ms 3776 KB Output is correct
5 Correct 72 ms 3136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 355 ms 12424 KB Output is correct
2 Correct 412 ms 15844 KB Output is correct
3 Correct 403 ms 15292 KB Output is correct
4 Correct 403 ms 17592 KB Output is correct
5 Correct 364 ms 14908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 446 ms 16332 KB Output is correct
2 Correct 427 ms 14776 KB Output is correct
3 Correct 359 ms 13892 KB Output is correct
4 Correct 400 ms 17460 KB Output is correct
5 Correct 374 ms 15428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 419 ms 14800 KB Output is correct
2 Correct 513 ms 18900 KB Output is correct
3 Correct 487 ms 18380 KB Output is correct
4 Correct 490 ms 21452 KB Output is correct
5 Correct 433 ms 17604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 519 ms 19676 KB Output is correct
2 Correct 525 ms 17616 KB Output is correct
3 Correct 435 ms 16464 KB Output is correct
4 Correct 489 ms 21332 KB Output is correct
5 Correct 447 ms 18504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 493 ms 17308 KB Output is correct
2 Correct 619 ms 22000 KB Output is correct
3 Correct 574 ms 21360 KB Output is correct
4 Correct 592 ms 24684 KB Output is correct
5 Correct 491 ms 20336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 614 ms 22900 KB Output is correct
2 Correct 567 ms 20548 KB Output is correct
3 Correct 498 ms 19584 KB Output is correct
4 Correct 572 ms 24624 KB Output is correct
5 Correct 512 ms 21492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 570 ms 19728 KB Output is correct
2 Correct 666 ms 25160 KB Output is correct
3 Correct 638 ms 24336 KB Output is correct
4 Correct 664 ms 28568 KB Output is correct
5 Correct 594 ms 23972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 701 ms 26004 KB Output is correct
2 Correct 645 ms 23492 KB Output is correct
3 Correct 576 ms 22340 KB Output is correct
4 Correct 651 ms 28228 KB Output is correct
5 Correct 607 ms 24404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 720 ms 24644 KB Output is correct
2 Correct 850 ms 31484 KB Output is correct
3 Correct 784 ms 30416 KB Output is correct
4 Correct 819 ms 35148 KB Output is correct
5 Correct 719 ms 29520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 898 ms 32460 KB Output is correct
2 Correct 827 ms 29160 KB Output is correct
3 Correct 739 ms 28244 KB Output is correct
4 Correct 832 ms 35404 KB Output is correct
5 Correct 736 ms 30672 KB Output is correct