记录编号 |
570841 |
评测结果 |
AAAAAA |
题目名称 |
喷水装置 |
最终得分 |
100 |
用户昵称 |
lihaoze |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.057 s |
提交时间 |
2022-04-20 19:55:59 |
内存使用 |
3.03 MiB |
显示代码纯文本
#include <bits/stdc++.h>
#define OPEN(x) freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout)
#define fi first
#define se second
using PDD = std::pair<double, double>;
int main() {
OPEN(sprinkler);
int t; std::cin >> t;
int n;
double l, w;
while (~scanf("%d%lf%lf", &n, &l, &w)) {
w /= 2;
std::vector<PDD> q;
for (int i = 1; i <= n; ++ i) {
double a, b;
scanf("%lf%lf", &a, &b);
if (b > w) {
double f = sqrt(b * b - w * w);
q.emplace_back(a - f, a + f);
}
}
std::sort(q.begin(), q.end(), [&](PDD x, PDD y) { return x.fi < y.fi; });
int len = q.size();
int flag = 0, ans = 0;
double st = 0, ed = l;
for (int i = 0; i < len; ++ i) {
int j = i; double res = -1e9;
while (j < len && q[j].fi <= st)
res = std::max(res, q[j++].se);
if (res <= st) break;
++ ans;
if (res >= ed) {
flag = 1;
break;
}
st = res;
i = j - 1;
}
if (flag) printf("%d\n", ans);
else puts("-1");
}
return 0;
}