#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const double EPS = 1e-9;
int N, R;
double Evaluate(lint a, lint b, lint c, lint d, double t) {
lint dx = c - a;
lint dy = d - b;
double x = (double) a + dx * t;
double y = (double) b + dy * t;
return x * x + y * y - (double(R) * double(R));
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> N >> R;
vector<pair<lint, lint>> segs;
for (int i = 0; i < N; i++) {
int a, b, c, d;
cin >> a >> b >> c >> d;
double lo = 0, hi = 4e8;
for (int rep = 0; rep < 160; rep++) {
double md1 = (lo + lo + hi) / 3;
double md2 = (lo + hi + hi) / 3;
if (Evaluate(a, b, c, d, md1) < Evaluate(a, b, c, d, md2)) {
hi = md2;
} else {
lo = md1;
}
}
if (Evaluate(a, b, c, d, lo) > 0) {
continue;
}
double piv = lo;
lint l, r;
{
lint lo = 0, hi = ceil(piv);
while (lo < hi) {
lint md = (lo + hi) / 2;
if (Evaluate(a, b, c, d, md) < EPS) {
hi = md;
} else {
lo = md + 1;
}
}
l = lo;
}
{
lint lo = floor(piv), hi = 4e8;
while (lo < hi) {
double md = (lo + hi + 1) / 2;
if (Evaluate(a, b, c, d, md) < EPS) {
lo = md;
} else {
hi = md - 1;
}
}
r = lo;
}
if (Evaluate(a, b, c, d, l) < EPS && Evaluate(a, b, c, d, r) < EPS && l <= r) {
segs.emplace_back(ceil(l), floor(r));
}
}
int ans = 0, cnt = 0;
sort(begin(segs), end(segs));
priority_queue<lint, vector<lint>, greater<lint>> pq;
for (auto i : segs) {
pq.emplace(i.second);
cnt++;
while (!pq.empty() && pq.top() < i.first) {
pq.pop();
cnt--;
}
ans = max(ans, cnt);
}
cout << ans << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
384 KB |
Output is correct |
20 |
Correct |
4 ms |
384 KB |
Output is correct |
21 |
Correct |
4 ms |
384 KB |
Output is correct |
22 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
384 KB |
Output is correct |
20 |
Correct |
4 ms |
384 KB |
Output is correct |
21 |
Correct |
4 ms |
384 KB |
Output is correct |
22 |
Correct |
4 ms |
384 KB |
Output is correct |
23 |
Correct |
324 ms |
3560 KB |
Output is correct |
24 |
Correct |
327 ms |
3560 KB |
Output is correct |
25 |
Correct |
321 ms |
3560 KB |
Output is correct |
26 |
Correct |
321 ms |
3560 KB |
Output is correct |
27 |
Correct |
322 ms |
2032 KB |
Output is correct |
28 |
Correct |
324 ms |
2652 KB |
Output is correct |
29 |
Correct |
325 ms |
2820 KB |
Output is correct |
30 |
Correct |
324 ms |
2716 KB |
Output is correct |
31 |
Correct |
323 ms |
2664 KB |
Output is correct |
32 |
Correct |
352 ms |
2540 KB |
Output is correct |
33 |
Correct |
352 ms |
2588 KB |
Output is correct |
34 |
Correct |
352 ms |
2540 KB |
Output is correct |
35 |
Correct |
350 ms |
2540 KB |
Output is correct |
36 |
Correct |
351 ms |
2712 KB |
Output is correct |
37 |
Correct |
326 ms |
2156 KB |
Output is correct |
38 |
Correct |
325 ms |
2156 KB |
Output is correct |
39 |
Correct |
326 ms |
1900 KB |
Output is correct |
40 |
Correct |
325 ms |
2028 KB |
Output is correct |
41 |
Correct |
327 ms |
2084 KB |
Output is correct |
42 |
Correct |
330 ms |
1900 KB |
Output is correct |
43 |
Correct |
720 ms |
7148 KB |
Output is correct |
44 |
Correct |
722 ms |
7132 KB |
Output is correct |
45 |
Correct |
723 ms |
7308 KB |
Output is correct |
46 |
Correct |
724 ms |
7188 KB |
Output is correct |
47 |
Correct |
731 ms |
7136 KB |
Output is correct |
48 |
Correct |
703 ms |
4588 KB |
Output is correct |
49 |
Correct |
704 ms |
4632 KB |
Output is correct |
50 |
Correct |
699 ms |
4580 KB |
Output is correct |
51 |
Correct |
697 ms |
4584 KB |
Output is correct |
52 |
Correct |
694 ms |
4716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
384 KB |
Output is correct |
20 |
Correct |
4 ms |
384 KB |
Output is correct |
21 |
Correct |
4 ms |
384 KB |
Output is correct |
22 |
Correct |
4 ms |
384 KB |
Output is correct |
23 |
Correct |
0 ms |
384 KB |
Output is correct |
24 |
Correct |
4 ms |
384 KB |
Output is correct |
25 |
Correct |
4 ms |
384 KB |
Output is correct |
26 |
Correct |
4 ms |
384 KB |
Output is correct |
27 |
Correct |
4 ms |
384 KB |
Output is correct |
28 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
384 KB |
Output is correct |
20 |
Correct |
4 ms |
384 KB |
Output is correct |
21 |
Correct |
4 ms |
384 KB |
Output is correct |
22 |
Correct |
4 ms |
384 KB |
Output is correct |
23 |
Correct |
324 ms |
3560 KB |
Output is correct |
24 |
Correct |
327 ms |
3560 KB |
Output is correct |
25 |
Correct |
321 ms |
3560 KB |
Output is correct |
26 |
Correct |
321 ms |
3560 KB |
Output is correct |
27 |
Correct |
322 ms |
2032 KB |
Output is correct |
28 |
Correct |
324 ms |
2652 KB |
Output is correct |
29 |
Correct |
325 ms |
2820 KB |
Output is correct |
30 |
Correct |
324 ms |
2716 KB |
Output is correct |
31 |
Correct |
323 ms |
2664 KB |
Output is correct |
32 |
Correct |
352 ms |
2540 KB |
Output is correct |
33 |
Correct |
352 ms |
2588 KB |
Output is correct |
34 |
Correct |
352 ms |
2540 KB |
Output is correct |
35 |
Correct |
350 ms |
2540 KB |
Output is correct |
36 |
Correct |
351 ms |
2712 KB |
Output is correct |
37 |
Correct |
326 ms |
2156 KB |
Output is correct |
38 |
Correct |
325 ms |
2156 KB |
Output is correct |
39 |
Correct |
326 ms |
1900 KB |
Output is correct |
40 |
Correct |
325 ms |
2028 KB |
Output is correct |
41 |
Correct |
327 ms |
2084 KB |
Output is correct |
42 |
Correct |
330 ms |
1900 KB |
Output is correct |
43 |
Correct |
720 ms |
7148 KB |
Output is correct |
44 |
Correct |
722 ms |
7132 KB |
Output is correct |
45 |
Correct |
723 ms |
7308 KB |
Output is correct |
46 |
Correct |
724 ms |
7188 KB |
Output is correct |
47 |
Correct |
731 ms |
7136 KB |
Output is correct |
48 |
Correct |
703 ms |
4588 KB |
Output is correct |
49 |
Correct |
704 ms |
4632 KB |
Output is correct |
50 |
Correct |
699 ms |
4580 KB |
Output is correct |
51 |
Correct |
697 ms |
4584 KB |
Output is correct |
52 |
Correct |
694 ms |
4716 KB |
Output is correct |
53 |
Correct |
320 ms |
3700 KB |
Output is correct |
54 |
Correct |
313 ms |
1548 KB |
Output is correct |
55 |
Correct |
314 ms |
1688 KB |
Output is correct |
56 |
Correct |
317 ms |
1648 KB |
Output is correct |
57 |
Correct |
325 ms |
1652 KB |
Output is correct |
58 |
Correct |
321 ms |
1524 KB |
Output is correct |
59 |
Correct |
325 ms |
1524 KB |
Output is correct |
60 |
Correct |
328 ms |
1524 KB |
Output is correct |
61 |
Correct |
328 ms |
1524 KB |
Output is correct |
62 |
Correct |
352 ms |
2516 KB |
Output is correct |
63 |
Correct |
349 ms |
2544 KB |
Output is correct |
64 |
Correct |
350 ms |
2652 KB |
Output is correct |
65 |
Correct |
348 ms |
2540 KB |
Output is correct |
66 |
Correct |
349 ms |
2544 KB |
Output is correct |
67 |
Correct |
323 ms |
2028 KB |
Output is correct |
68 |
Correct |
330 ms |
2540 KB |
Output is correct |
69 |
Correct |
326 ms |
2540 KB |
Output is correct |
70 |
Correct |
332 ms |
2012 KB |
Output is correct |
71 |
Correct |
705 ms |
6368 KB |
Output is correct |
72 |
Correct |
710 ms |
6368 KB |
Output is correct |
73 |
Correct |
706 ms |
6556 KB |
Output is correct |
74 |
Correct |
708 ms |
6488 KB |
Output is correct |
75 |
Correct |
710 ms |
6500 KB |
Output is correct |
76 |
Correct |
709 ms |
4712 KB |
Output is correct |
77 |
Correct |
704 ms |
4608 KB |
Output is correct |
78 |
Correct |
708 ms |
4720 KB |
Output is correct |
79 |
Correct |
696 ms |
4596 KB |
Output is correct |
80 |
Correct |
702 ms |
4584 KB |
Output is correct |
81 |
Correct |
0 ms |
384 KB |
Output is correct |
82 |
Correct |
4 ms |
384 KB |
Output is correct |
83 |
Correct |
4 ms |
384 KB |
Output is correct |
84 |
Correct |
4 ms |
384 KB |
Output is correct |
85 |
Correct |
4 ms |
384 KB |
Output is correct |
86 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
384 KB |
Output is correct |
20 |
Correct |
4 ms |
384 KB |
Output is correct |
21 |
Correct |
4 ms |
384 KB |
Output is correct |
22 |
Correct |
4 ms |
384 KB |
Output is correct |
23 |
Correct |
324 ms |
3560 KB |
Output is correct |
24 |
Correct |
327 ms |
3560 KB |
Output is correct |
25 |
Correct |
321 ms |
3560 KB |
Output is correct |
26 |
Correct |
321 ms |
3560 KB |
Output is correct |
27 |
Correct |
322 ms |
2032 KB |
Output is correct |
28 |
Correct |
324 ms |
2652 KB |
Output is correct |
29 |
Correct |
325 ms |
2820 KB |
Output is correct |
30 |
Correct |
324 ms |
2716 KB |
Output is correct |
31 |
Correct |
323 ms |
2664 KB |
Output is correct |
32 |
Correct |
352 ms |
2540 KB |
Output is correct |
33 |
Correct |
352 ms |
2588 KB |
Output is correct |
34 |
Correct |
352 ms |
2540 KB |
Output is correct |
35 |
Correct |
350 ms |
2540 KB |
Output is correct |
36 |
Correct |
351 ms |
2712 KB |
Output is correct |
37 |
Correct |
326 ms |
2156 KB |
Output is correct |
38 |
Correct |
325 ms |
2156 KB |
Output is correct |
39 |
Correct |
326 ms |
1900 KB |
Output is correct |
40 |
Correct |
325 ms |
2028 KB |
Output is correct |
41 |
Correct |
327 ms |
2084 KB |
Output is correct |
42 |
Correct |
330 ms |
1900 KB |
Output is correct |
43 |
Correct |
720 ms |
7148 KB |
Output is correct |
44 |
Correct |
722 ms |
7132 KB |
Output is correct |
45 |
Correct |
723 ms |
7308 KB |
Output is correct |
46 |
Correct |
724 ms |
7188 KB |
Output is correct |
47 |
Correct |
731 ms |
7136 KB |
Output is correct |
48 |
Correct |
703 ms |
4588 KB |
Output is correct |
49 |
Correct |
704 ms |
4632 KB |
Output is correct |
50 |
Correct |
699 ms |
4580 KB |
Output is correct |
51 |
Correct |
697 ms |
4584 KB |
Output is correct |
52 |
Correct |
694 ms |
4716 KB |
Output is correct |
53 |
Correct |
320 ms |
3700 KB |
Output is correct |
54 |
Correct |
313 ms |
1548 KB |
Output is correct |
55 |
Correct |
314 ms |
1688 KB |
Output is correct |
56 |
Correct |
317 ms |
1648 KB |
Output is correct |
57 |
Correct |
325 ms |
1652 KB |
Output is correct |
58 |
Correct |
321 ms |
1524 KB |
Output is correct |
59 |
Correct |
325 ms |
1524 KB |
Output is correct |
60 |
Correct |
328 ms |
1524 KB |
Output is correct |
61 |
Correct |
328 ms |
1524 KB |
Output is correct |
62 |
Correct |
352 ms |
2516 KB |
Output is correct |
63 |
Correct |
349 ms |
2544 KB |
Output is correct |
64 |
Correct |
350 ms |
2652 KB |
Output is correct |
65 |
Correct |
348 ms |
2540 KB |
Output is correct |
66 |
Correct |
349 ms |
2544 KB |
Output is correct |
67 |
Correct |
323 ms |
2028 KB |
Output is correct |
68 |
Correct |
330 ms |
2540 KB |
Output is correct |
69 |
Correct |
326 ms |
2540 KB |
Output is correct |
70 |
Correct |
332 ms |
2012 KB |
Output is correct |
71 |
Correct |
705 ms |
6368 KB |
Output is correct |
72 |
Correct |
710 ms |
6368 KB |
Output is correct |
73 |
Correct |
706 ms |
6556 KB |
Output is correct |
74 |
Correct |
708 ms |
6488 KB |
Output is correct |
75 |
Correct |
710 ms |
6500 KB |
Output is correct |
76 |
Correct |
709 ms |
4712 KB |
Output is correct |
77 |
Correct |
704 ms |
4608 KB |
Output is correct |
78 |
Correct |
708 ms |
4720 KB |
Output is correct |
79 |
Correct |
696 ms |
4596 KB |
Output is correct |
80 |
Correct |
702 ms |
4584 KB |
Output is correct |
81 |
Correct |
352 ms |
1580 KB |
Output is correct |
82 |
Correct |
350 ms |
1652 KB |
Output is correct |
83 |
Correct |
347 ms |
1524 KB |
Output is correct |
84 |
Correct |
345 ms |
1524 KB |
Output is correct |
85 |
Correct |
346 ms |
1548 KB |
Output is correct |
86 |
Correct |
353 ms |
1524 KB |
Output is correct |
87 |
Correct |
356 ms |
1524 KB |
Output is correct |
88 |
Correct |
361 ms |
1532 KB |
Output is correct |
89 |
Correct |
355 ms |
1528 KB |
Output is correct |
90 |
Correct |
356 ms |
1652 KB |
Output is correct |
91 |
Correct |
330 ms |
3688 KB |
Output is correct |
92 |
Correct |
335 ms |
4008 KB |
Output is correct |
93 |
Correct |
335 ms |
3568 KB |
Output is correct |
94 |
Correct |
338 ms |
3736 KB |
Output is correct |
95 |
Correct |
334 ms |
3740 KB |
Output is correct |
96 |
Correct |
334 ms |
3556 KB |
Output is correct |
97 |
Correct |
333 ms |
3560 KB |
Output is correct |
98 |
Correct |
330 ms |
3560 KB |
Output is correct |
99 |
Correct |
331 ms |
3684 KB |
Output is correct |
100 |
Correct |
332 ms |
3652 KB |
Output is correct |
101 |
Correct |
0 ms |
384 KB |
Output is correct |
102 |
Correct |
4 ms |
384 KB |
Output is correct |
103 |
Correct |
4 ms |
384 KB |
Output is correct |
104 |
Correct |
4 ms |
384 KB |
Output is correct |
105 |
Correct |
4 ms |
384 KB |
Output is correct |
106 |
Correct |
4 ms |
384 KB |
Output is correct |