Submission #314062

# Submission time Handle Problem Language Result Execution time Memory
314062 2020-10-18T03:41:41 Z shrek12357 Mobile (BOI12_mobile) C++14
90 / 100
1000 ms 16152 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
#define ll long long
//cin.tie(0); ios_base::sync_with_stdio(0); 

const int MAXN = 1e6 + 5;

double n, l;
vector<pair<double, double>> points(MAXN);

bool check(double mid) {
	double left = 0;
	for (int i = 0; i < points.size(); i++) {
		if (left >= l) {
			return true;
		}
		if (mid < points[i].second) {
			continue;
		}
		double temp = sqrt(mid*mid - points[i].second*points[i].second);
		if (points[i].first - temp <= left) {
			left = max(points[i].first + temp, left);
		}
	}
	return left >= l;
}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(0); 
	cin >> n >> l;
	for (int i = 0; i < n; i++) {
		double a, b;
		cin >> a >> b;
		points[i] = make_pair( a, b );
	}
	double lo = 0;
	double hi = 1e9;
	double ans = 1e10;
	while (hi - lo > 1e-3) {
		double mid = (lo + hi) / 2;
		if (check(mid)) {
			ans = min(ans, mid);
			hi = mid;
		}
		else {
			lo = mid;
		}
	}
	printf("%.7lf\n", ans);
}

Compilation message

mobile.cpp: In function 'bool check(double)':
mobile.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for (int i = 0; i < points.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 43 ms 16000 KB Output is correct
2 Correct 39 ms 16000 KB Output is correct
3 Correct 44 ms 16000 KB Output is correct
4 Correct 55 ms 16000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 16052 KB Output is correct
2 Correct 39 ms 16000 KB Output is correct
3 Correct 61 ms 16000 KB Output is correct
4 Correct 77 ms 16000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 16000 KB Output is correct
2 Correct 44 ms 16032 KB Output is correct
3 Correct 67 ms 16120 KB Output is correct
4 Correct 77 ms 16120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 16000 KB Output is correct
2 Correct 103 ms 16000 KB Output is correct
3 Correct 84 ms 16000 KB Output is correct
4 Correct 87 ms 16120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 16000 KB Output is correct
2 Correct 104 ms 16000 KB Output is correct
3 Correct 56 ms 16000 KB Output is correct
4 Correct 99 ms 16120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 16056 KB Output is correct
2 Correct 102 ms 16052 KB Output is correct
3 Correct 81 ms 16000 KB Output is correct
4 Correct 99 ms 16000 KB Output is correct
5 Correct 64 ms 16000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 116 ms 16056 KB Output is correct
2 Correct 168 ms 16000 KB Output is correct
3 Correct 89 ms 16000 KB Output is correct
4 Correct 161 ms 16000 KB Output is correct
5 Correct 70 ms 16056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 16000 KB Output is correct
2 Correct 111 ms 16120 KB Output is correct
3 Correct 140 ms 16000 KB Output is correct
4 Correct 159 ms 16000 KB Output is correct
5 Correct 188 ms 16120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 142 ms 16000 KB Output is correct
2 Correct 146 ms 16052 KB Output is correct
3 Correct 103 ms 16000 KB Output is correct
4 Correct 208 ms 16120 KB Output is correct
5 Correct 107 ms 16000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 231 ms 16000 KB Output is correct
2 Correct 185 ms 16000 KB Output is correct
3 Correct 138 ms 16000 KB Output is correct
4 Correct 202 ms 16000 KB Output is correct
5 Correct 142 ms 16000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 16120 KB Output is correct
2 Correct 187 ms 16000 KB Output is correct
3 Correct 139 ms 16000 KB Output is correct
4 Correct 198 ms 16120 KB Output is correct
5 Correct 135 ms 16000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 399 ms 16052 KB Output is correct
2 Correct 410 ms 16048 KB Output is correct
3 Correct 362 ms 16120 KB Output is correct
4 Correct 558 ms 16124 KB Output is correct
5 Correct 464 ms 16120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 493 ms 16052 KB Output is correct
2 Correct 423 ms 16120 KB Output is correct
3 Correct 342 ms 16120 KB Output is correct
4 Correct 588 ms 16124 KB Output is correct
5 Correct 495 ms 16120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 464 ms 16056 KB Output is correct
2 Correct 458 ms 16120 KB Output is correct
3 Correct 407 ms 16120 KB Output is correct
4 Correct 700 ms 16120 KB Output is correct
5 Correct 544 ms 16052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 546 ms 16056 KB Output is correct
2 Correct 482 ms 16000 KB Output is correct
3 Correct 413 ms 16000 KB Output is correct
4 Correct 706 ms 16000 KB Output is correct
5 Correct 576 ms 16056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 512 ms 16152 KB Output is correct
2 Correct 547 ms 16056 KB Output is correct
3 Correct 499 ms 16120 KB Output is correct
4 Correct 788 ms 16056 KB Output is correct
5 Correct 596 ms 16052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 585 ms 16056 KB Output is correct
2 Correct 555 ms 16000 KB Output is correct
3 Correct 467 ms 16000 KB Output is correct
4 Correct 775 ms 16000 KB Output is correct
5 Correct 668 ms 16000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 567 ms 16000 KB Output is correct
2 Correct 613 ms 16000 KB Output is correct
3 Correct 524 ms 16120 KB Output is correct
4 Correct 885 ms 16120 KB Output is correct
5 Correct 719 ms 16052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 681 ms 16120 KB Output is correct
2 Correct 617 ms 16056 KB Output is correct
3 Correct 479 ms 16052 KB Output is correct
4 Correct 887 ms 16000 KB Output is correct
5 Correct 733 ms 16060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 675 ms 16052 KB Output is correct
2 Correct 678 ms 16120 KB Output is correct
3 Correct 691 ms 16056 KB Output is correct
4 Execution timed out 1073 ms 16120 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 830 ms 16052 KB Output is correct
2 Correct 739 ms 16000 KB Output is correct
3 Correct 636 ms 16120 KB Output is correct
4 Execution timed out 1095 ms 16000 KB Time limit exceeded
5 Halted 0 ms 0 KB -