Submission #671149

# Submission time Handle Problem Language Result Execution time Memory
671149 2022-12-12T08:22:47 Z vjudge1 Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 64232 KB
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
using vi = vector<int>;
using ll = long long;
using pii = pair<ll, int>;

const int maxn = 2e6 + 7;
double x[maxn], y[maxn];
pair<double, int> pt[maxn];
double L;
int n;

bool check(double r) {
	int m = 0;
	rep(i, 0, n) {
		if (abs(y[i]) < r) {
			double dy = abs(y[i]);
			double tmp = r * r - dy * dy;
			double dx = sqrt(tmp);
			double x1 = x[i] - dx, x2 = x[i] + dx;
			pt[m].f = max(0.0, x1); pt[m].s = -1; m++;
			pt[m].f = min(L, x2); pt[m].s = 1; m++;
		} 
	}
	sort(pt, pt + m);
	stack<double> st;
	double len = 0.0;
	rep(i, 0, m) {
		if (pt[i].s == -1) {
			st.push(pt[i].f);
		} else {
			double dis = pt[i].f - st.top();
			st.pop();
			if (st.empty()) {
				len += dis;
			}
		}
	}
	return len >= L;
}

int main() {
	//ios::sync_with_stdio(false);
	scanf("%d %lf", &n, &L);
	rep(i, 0, n) {
		scanf("%lf %lf", &x[i], &y[i]);
	}
	double l = 0.0, r = 1e9;
	rep(it, 0, 70) {
		double mid = l + (r - l) / 2;
		if (check(mid)) {
			r = mid;
		} else {
			l = mid;
		}
	}
	printf("%.6lf\n", l);
}	

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:63:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |  scanf("%d %lf", &n, &L);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
mobile.cpp:65:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |   scanf("%lf %lf", &x[i], &y[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 79 ms 9504 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 103 ms 9848 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 572 ms 5836 KB Output is correct
2 Correct 493 ms 6012 KB Output is correct
3 Correct 410 ms 5924 KB Output is correct
4 Runtime error 58 ms 13456 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 586 ms 7384 KB Output is correct
2 Correct 645 ms 7236 KB Output is correct
3 Correct 494 ms 6856 KB Output is correct
4 Runtime error 57 ms 13596 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 60 ms 13100 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 32244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 36148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 38652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 42500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 44992 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1031 ms 48052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 51416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 53536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 64232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 60640 KB Time limit exceeded
2 Halted 0 ms 0 KB -