#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
long double r;
cin >> n >> r;
vector<pair<long double, int>> stars;
FOR(i, 0, n) {
long double x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x1 == x2) swap(x1, y1), swap(x2, y2);
long double v = x2 - x1;
long double m = (y1 - y2) / (x1 - x2);
long double c = y1 - m * x1;
if (m * m * c * c < (m * m + 1) * (c * c - r * r)) continue;
long double int_1 =
(-m * c + sqrt(m * m * c * c - (m * m + 1) * (c * c - r * r))) /
(m * m + 1);
long double int_2 =
(-m * c - sqrt(m * m * c * c - (m * m + 1) * (c * c - r * r))) /
(m * m + 1);
if ((int_1 - x1) / v > (int_2 - x1) / v) swap(int_1, int_2);
stars.push_back({ceil((int_1 - x1) / v), -1});
stars.push_back({floor((int_2 - x1) / v), 1});
}
stars.push_back({0, 0});
sort(stars.begin(), stars.end());
int ans = 0, cnt = 0;
for (pair<long double, int> i : stars) {
cnt -= i.second;
if (i.first >= 0) ans = max(ans, cnt);
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
7 ms |
512 KB |
Output is correct |
4 |
Correct |
7 ms |
512 KB |
Output is correct |
5 |
Correct |
6 ms |
416 KB |
Output is correct |
6 |
Correct |
7 ms |
512 KB |
Output is correct |
7 |
Correct |
6 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
512 KB |
Output is correct |
15 |
Correct |
6 ms |
512 KB |
Output is correct |
16 |
Correct |
6 ms |
512 KB |
Output is correct |
17 |
Correct |
6 ms |
512 KB |
Output is correct |
18 |
Correct |
6 ms |
512 KB |
Output is correct |
19 |
Correct |
6 ms |
512 KB |
Output is correct |
20 |
Correct |
6 ms |
512 KB |
Output is correct |
21 |
Correct |
6 ms |
512 KB |
Output is correct |
22 |
Correct |
6 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
7 ms |
512 KB |
Output is correct |
4 |
Correct |
7 ms |
512 KB |
Output is correct |
5 |
Correct |
6 ms |
416 KB |
Output is correct |
6 |
Correct |
7 ms |
512 KB |
Output is correct |
7 |
Correct |
6 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
512 KB |
Output is correct |
15 |
Correct |
6 ms |
512 KB |
Output is correct |
16 |
Correct |
6 ms |
512 KB |
Output is correct |
17 |
Correct |
6 ms |
512 KB |
Output is correct |
18 |
Correct |
6 ms |
512 KB |
Output is correct |
19 |
Correct |
6 ms |
512 KB |
Output is correct |
20 |
Correct |
6 ms |
512 KB |
Output is correct |
21 |
Correct |
6 ms |
512 KB |
Output is correct |
22 |
Correct |
6 ms |
512 KB |
Output is correct |
23 |
Correct |
134 ms |
8800 KB |
Output is correct |
24 |
Correct |
135 ms |
8800 KB |
Output is correct |
25 |
Correct |
133 ms |
8864 KB |
Output is correct |
26 |
Correct |
133 ms |
8804 KB |
Output is correct |
27 |
Correct |
150 ms |
8800 KB |
Output is correct |
28 |
Correct |
137 ms |
8800 KB |
Output is correct |
29 |
Correct |
142 ms |
8932 KB |
Output is correct |
30 |
Correct |
140 ms |
8800 KB |
Output is correct |
31 |
Correct |
141 ms |
8804 KB |
Output is correct |
32 |
Correct |
158 ms |
8928 KB |
Output is correct |
33 |
Correct |
154 ms |
8960 KB |
Output is correct |
34 |
Correct |
153 ms |
8804 KB |
Output is correct |
35 |
Correct |
152 ms |
8800 KB |
Output is correct |
36 |
Correct |
148 ms |
8800 KB |
Output is correct |
37 |
Correct |
140 ms |
8800 KB |
Output is correct |
38 |
Correct |
141 ms |
8796 KB |
Output is correct |
39 |
Correct |
144 ms |
8800 KB |
Output is correct |
40 |
Correct |
162 ms |
8888 KB |
Output is correct |
41 |
Correct |
140 ms |
8804 KB |
Output is correct |
42 |
Correct |
144 ms |
8796 KB |
Output is correct |
43 |
Correct |
329 ms |
17232 KB |
Output is correct |
44 |
Correct |
321 ms |
17108 KB |
Output is correct |
45 |
Correct |
320 ms |
17148 KB |
Output is correct |
46 |
Correct |
328 ms |
16980 KB |
Output is correct |
47 |
Correct |
320 ms |
16980 KB |
Output is correct |
48 |
Correct |
323 ms |
16980 KB |
Output is correct |
49 |
Correct |
303 ms |
16980 KB |
Output is correct |
50 |
Correct |
313 ms |
16984 KB |
Output is correct |
51 |
Correct |
305 ms |
16980 KB |
Output is correct |
52 |
Correct |
307 ms |
17048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
7 ms |
512 KB |
Output is correct |
4 |
Correct |
7 ms |
512 KB |
Output is correct |
5 |
Correct |
6 ms |
416 KB |
Output is correct |
6 |
Correct |
7 ms |
512 KB |
Output is correct |
7 |
Correct |
6 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
512 KB |
Output is correct |
15 |
Correct |
6 ms |
512 KB |
Output is correct |
16 |
Correct |
6 ms |
512 KB |
Output is correct |
17 |
Correct |
6 ms |
512 KB |
Output is correct |
18 |
Correct |
6 ms |
512 KB |
Output is correct |
19 |
Correct |
6 ms |
512 KB |
Output is correct |
20 |
Correct |
6 ms |
512 KB |
Output is correct |
21 |
Correct |
6 ms |
512 KB |
Output is correct |
22 |
Correct |
6 ms |
512 KB |
Output is correct |
23 |
Correct |
4 ms |
384 KB |
Output is correct |
24 |
Correct |
6 ms |
512 KB |
Output is correct |
25 |
Correct |
7 ms |
512 KB |
Output is correct |
26 |
Correct |
6 ms |
512 KB |
Output is correct |
27 |
Correct |
6 ms |
512 KB |
Output is correct |
28 |
Correct |
6 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
7 ms |
512 KB |
Output is correct |
4 |
Correct |
7 ms |
512 KB |
Output is correct |
5 |
Correct |
6 ms |
416 KB |
Output is correct |
6 |
Correct |
7 ms |
512 KB |
Output is correct |
7 |
Correct |
6 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
512 KB |
Output is correct |
15 |
Correct |
6 ms |
512 KB |
Output is correct |
16 |
Correct |
6 ms |
512 KB |
Output is correct |
17 |
Correct |
6 ms |
512 KB |
Output is correct |
18 |
Correct |
6 ms |
512 KB |
Output is correct |
19 |
Correct |
6 ms |
512 KB |
Output is correct |
20 |
Correct |
6 ms |
512 KB |
Output is correct |
21 |
Correct |
6 ms |
512 KB |
Output is correct |
22 |
Correct |
6 ms |
512 KB |
Output is correct |
23 |
Correct |
134 ms |
8800 KB |
Output is correct |
24 |
Correct |
135 ms |
8800 KB |
Output is correct |
25 |
Correct |
133 ms |
8864 KB |
Output is correct |
26 |
Correct |
133 ms |
8804 KB |
Output is correct |
27 |
Correct |
150 ms |
8800 KB |
Output is correct |
28 |
Correct |
137 ms |
8800 KB |
Output is correct |
29 |
Correct |
142 ms |
8932 KB |
Output is correct |
30 |
Correct |
140 ms |
8800 KB |
Output is correct |
31 |
Correct |
141 ms |
8804 KB |
Output is correct |
32 |
Correct |
158 ms |
8928 KB |
Output is correct |
33 |
Correct |
154 ms |
8960 KB |
Output is correct |
34 |
Correct |
153 ms |
8804 KB |
Output is correct |
35 |
Correct |
152 ms |
8800 KB |
Output is correct |
36 |
Correct |
148 ms |
8800 KB |
Output is correct |
37 |
Correct |
140 ms |
8800 KB |
Output is correct |
38 |
Correct |
141 ms |
8796 KB |
Output is correct |
39 |
Correct |
144 ms |
8800 KB |
Output is correct |
40 |
Correct |
162 ms |
8888 KB |
Output is correct |
41 |
Correct |
140 ms |
8804 KB |
Output is correct |
42 |
Correct |
144 ms |
8796 KB |
Output is correct |
43 |
Correct |
329 ms |
17232 KB |
Output is correct |
44 |
Correct |
321 ms |
17108 KB |
Output is correct |
45 |
Correct |
320 ms |
17148 KB |
Output is correct |
46 |
Correct |
328 ms |
16980 KB |
Output is correct |
47 |
Correct |
320 ms |
16980 KB |
Output is correct |
48 |
Correct |
323 ms |
16980 KB |
Output is correct |
49 |
Correct |
303 ms |
16980 KB |
Output is correct |
50 |
Correct |
313 ms |
16984 KB |
Output is correct |
51 |
Correct |
305 ms |
16980 KB |
Output is correct |
52 |
Correct |
307 ms |
17048 KB |
Output is correct |
53 |
Correct |
147 ms |
8800 KB |
Output is correct |
54 |
Correct |
152 ms |
8800 KB |
Output is correct |
55 |
Correct |
144 ms |
10596 KB |
Output is correct |
56 |
Correct |
142 ms |
10464 KB |
Output is correct |
57 |
Correct |
157 ms |
10764 KB |
Output is correct |
58 |
Correct |
160 ms |
10596 KB |
Output is correct |
59 |
Correct |
157 ms |
10592 KB |
Output is correct |
60 |
Correct |
157 ms |
10720 KB |
Output is correct |
61 |
Correct |
154 ms |
10592 KB |
Output is correct |
62 |
Correct |
157 ms |
10208 KB |
Output is correct |
63 |
Correct |
157 ms |
10208 KB |
Output is correct |
64 |
Correct |
158 ms |
10336 KB |
Output is correct |
65 |
Correct |
162 ms |
10212 KB |
Output is correct |
66 |
Correct |
160 ms |
10208 KB |
Output is correct |
67 |
Correct |
138 ms |
9824 KB |
Output is correct |
68 |
Correct |
140 ms |
9956 KB |
Output is correct |
69 |
Correct |
150 ms |
9996 KB |
Output is correct |
70 |
Correct |
145 ms |
9952 KB |
Output is correct |
71 |
Correct |
330 ms |
20020 KB |
Output is correct |
72 |
Correct |
338 ms |
19924 KB |
Output is correct |
73 |
Correct |
322 ms |
19924 KB |
Output is correct |
74 |
Correct |
322 ms |
19924 KB |
Output is correct |
75 |
Correct |
324 ms |
19920 KB |
Output is correct |
76 |
Correct |
305 ms |
19668 KB |
Output is correct |
77 |
Correct |
312 ms |
19784 KB |
Output is correct |
78 |
Correct |
304 ms |
19740 KB |
Output is correct |
79 |
Correct |
316 ms |
19668 KB |
Output is correct |
80 |
Correct |
316 ms |
19668 KB |
Output is correct |
81 |
Correct |
4 ms |
384 KB |
Output is correct |
82 |
Correct |
6 ms |
512 KB |
Output is correct |
83 |
Correct |
7 ms |
512 KB |
Output is correct |
84 |
Correct |
6 ms |
512 KB |
Output is correct |
85 |
Correct |
6 ms |
512 KB |
Output is correct |
86 |
Correct |
6 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
7 ms |
512 KB |
Output is correct |
4 |
Correct |
7 ms |
512 KB |
Output is correct |
5 |
Correct |
6 ms |
416 KB |
Output is correct |
6 |
Correct |
7 ms |
512 KB |
Output is correct |
7 |
Correct |
6 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
512 KB |
Output is correct |
15 |
Correct |
6 ms |
512 KB |
Output is correct |
16 |
Correct |
6 ms |
512 KB |
Output is correct |
17 |
Correct |
6 ms |
512 KB |
Output is correct |
18 |
Correct |
6 ms |
512 KB |
Output is correct |
19 |
Correct |
6 ms |
512 KB |
Output is correct |
20 |
Correct |
6 ms |
512 KB |
Output is correct |
21 |
Correct |
6 ms |
512 KB |
Output is correct |
22 |
Correct |
6 ms |
512 KB |
Output is correct |
23 |
Correct |
134 ms |
8800 KB |
Output is correct |
24 |
Correct |
135 ms |
8800 KB |
Output is correct |
25 |
Correct |
133 ms |
8864 KB |
Output is correct |
26 |
Correct |
133 ms |
8804 KB |
Output is correct |
27 |
Correct |
150 ms |
8800 KB |
Output is correct |
28 |
Correct |
137 ms |
8800 KB |
Output is correct |
29 |
Correct |
142 ms |
8932 KB |
Output is correct |
30 |
Correct |
140 ms |
8800 KB |
Output is correct |
31 |
Correct |
141 ms |
8804 KB |
Output is correct |
32 |
Correct |
158 ms |
8928 KB |
Output is correct |
33 |
Correct |
154 ms |
8960 KB |
Output is correct |
34 |
Correct |
153 ms |
8804 KB |
Output is correct |
35 |
Correct |
152 ms |
8800 KB |
Output is correct |
36 |
Correct |
148 ms |
8800 KB |
Output is correct |
37 |
Correct |
140 ms |
8800 KB |
Output is correct |
38 |
Correct |
141 ms |
8796 KB |
Output is correct |
39 |
Correct |
144 ms |
8800 KB |
Output is correct |
40 |
Correct |
162 ms |
8888 KB |
Output is correct |
41 |
Correct |
140 ms |
8804 KB |
Output is correct |
42 |
Correct |
144 ms |
8796 KB |
Output is correct |
43 |
Correct |
329 ms |
17232 KB |
Output is correct |
44 |
Correct |
321 ms |
17108 KB |
Output is correct |
45 |
Correct |
320 ms |
17148 KB |
Output is correct |
46 |
Correct |
328 ms |
16980 KB |
Output is correct |
47 |
Correct |
320 ms |
16980 KB |
Output is correct |
48 |
Correct |
323 ms |
16980 KB |
Output is correct |
49 |
Correct |
303 ms |
16980 KB |
Output is correct |
50 |
Correct |
313 ms |
16984 KB |
Output is correct |
51 |
Correct |
305 ms |
16980 KB |
Output is correct |
52 |
Correct |
307 ms |
17048 KB |
Output is correct |
53 |
Correct |
147 ms |
8800 KB |
Output is correct |
54 |
Correct |
152 ms |
8800 KB |
Output is correct |
55 |
Correct |
144 ms |
10596 KB |
Output is correct |
56 |
Correct |
142 ms |
10464 KB |
Output is correct |
57 |
Correct |
157 ms |
10764 KB |
Output is correct |
58 |
Correct |
160 ms |
10596 KB |
Output is correct |
59 |
Correct |
157 ms |
10592 KB |
Output is correct |
60 |
Correct |
157 ms |
10720 KB |
Output is correct |
61 |
Correct |
154 ms |
10592 KB |
Output is correct |
62 |
Correct |
157 ms |
10208 KB |
Output is correct |
63 |
Correct |
157 ms |
10208 KB |
Output is correct |
64 |
Correct |
158 ms |
10336 KB |
Output is correct |
65 |
Correct |
162 ms |
10212 KB |
Output is correct |
66 |
Correct |
160 ms |
10208 KB |
Output is correct |
67 |
Correct |
138 ms |
9824 KB |
Output is correct |
68 |
Correct |
140 ms |
9956 KB |
Output is correct |
69 |
Correct |
150 ms |
9996 KB |
Output is correct |
70 |
Correct |
145 ms |
9952 KB |
Output is correct |
71 |
Correct |
330 ms |
20020 KB |
Output is correct |
72 |
Correct |
338 ms |
19924 KB |
Output is correct |
73 |
Correct |
322 ms |
19924 KB |
Output is correct |
74 |
Correct |
322 ms |
19924 KB |
Output is correct |
75 |
Correct |
324 ms |
19920 KB |
Output is correct |
76 |
Correct |
305 ms |
19668 KB |
Output is correct |
77 |
Correct |
312 ms |
19784 KB |
Output is correct |
78 |
Correct |
304 ms |
19740 KB |
Output is correct |
79 |
Correct |
316 ms |
19668 KB |
Output is correct |
80 |
Correct |
316 ms |
19668 KB |
Output is correct |
81 |
Correct |
181 ms |
12008 KB |
Output is correct |
82 |
Correct |
182 ms |
11872 KB |
Output is correct |
83 |
Correct |
190 ms |
11952 KB |
Output is correct |
84 |
Correct |
195 ms |
11964 KB |
Output is correct |
85 |
Correct |
185 ms |
11868 KB |
Output is correct |
86 |
Correct |
183 ms |
11872 KB |
Output is correct |
87 |
Correct |
187 ms |
11872 KB |
Output is correct |
88 |
Correct |
181 ms |
11912 KB |
Output is correct |
89 |
Correct |
187 ms |
11876 KB |
Output is correct |
90 |
Correct |
182 ms |
11872 KB |
Output is correct |
91 |
Correct |
154 ms |
10456 KB |
Output is correct |
92 |
Correct |
147 ms |
10464 KB |
Output is correct |
93 |
Correct |
150 ms |
10592 KB |
Output is correct |
94 |
Correct |
150 ms |
10464 KB |
Output is correct |
95 |
Correct |
146 ms |
10464 KB |
Output is correct |
96 |
Correct |
151 ms |
10536 KB |
Output is correct |
97 |
Correct |
148 ms |
10464 KB |
Output is correct |
98 |
Correct |
146 ms |
10516 KB |
Output is correct |
99 |
Correct |
151 ms |
10464 KB |
Output is correct |
100 |
Correct |
152 ms |
10464 KB |
Output is correct |
101 |
Correct |
4 ms |
384 KB |
Output is correct |
102 |
Correct |
6 ms |
512 KB |
Output is correct |
103 |
Correct |
7 ms |
512 KB |
Output is correct |
104 |
Correct |
6 ms |
512 KB |
Output is correct |
105 |
Correct |
6 ms |
512 KB |
Output is correct |
106 |
Correct |
6 ms |
512 KB |
Output is correct |