Submission #417533

# Submission time Handle Problem Language Result Execution time Memory
417533 2021-06-03T21:21:29 Z jackkkk Mobile (BOI12_mobile) C++11
0 / 100
1000 ms 32540 KB
#include <stdio.h>
#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;
vector <pair<double ,double>> intervals;
bool good(double dist){
    intervals.clear();
    //get_intervals
    double mx = 0;
    for(const auto &tower : towers){
        if(tower.second>dist){
            continue;
        }
        double range = sqrt((dist*dist)-(tower.second*tower.second));
        intervals.emplace_back(tower.first-range, tower.first+range);
        mx = max(mx, tower.first+range);
        
    }
    sort(intervals.begin(), intervals.end());
    if(intervals[0].first>0){
        return false;
    }
    double curr_max = intervals[0].second;
    
    for(int i = 1; i < (int) intervals.size(); i++){
        if(curr_max<intervals[i].first){
            break;
        }
        curr_max=max(curr_max, intervals[i].second);
    }
	if(curr_max<l){
		return false;
	}
    return true;
}
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 = 1e13, mid;
    while(e-s>0.001){
        mid = (s+e)/2;
        if(good(mid)){
            e=mid;
        }
        else{
            s=mid;
        }
    }
    cout << e << "\n";
	quit();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 612 KB Output is correct
2 Incorrect 10 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 145 ms 3648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 248 ms 3712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 183 ms 3860 KB Output is correct
2 Incorrect 289 ms 3772 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 286 ms 4052 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 226 ms 4032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 16452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 16568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 26196 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 26204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 27828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 27828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 29328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 29324 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 32540 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 32500 KB Time limit exceeded
2 Halted 0 ms 0 KB -