#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-13;
void solve() {
int n; long long r;
cin >> n >> r;
vector<long long> a(n), b(n), c(n), d(n);
for (int i=0; i<n; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
vector<pair<long long, bool>> evs;
for (int i=0; i<n; i++) {
// p(t) = (a[i] + t * dx, b[i] + t * dy)
// cari t sehingga (a[i] + t * dx)^2 + (b[i] + t * dy)^2 = r^2
// => a[i]^2 + t^2*dx^2 + 2*t*a[i]*dx + b[i]^2 + t^2*dy^2 + 2*t*b[i]*dy = r^2
// => t^2 * (dx^2 + dy^2) + t * (2*a[i]*dx + 2*b[i]*dy) + a[i]^2 + b[i]^2 - r^2 = 0
// => t^2 * A + t * B + C = 0
// pakai rumus akar persamaan kuadrat?
long long dx = c[i] - a[i], dy = d[i] - b[i];
long long A = dx * dx + dy * dy, B = 2 * (a[i] * dx + b[i] * dy), C = a[i] * a[i] + b[i] * b[i] - r * r;
long long D = B * B - 4 * A * C;
if (D >= 0) {
double sd = sqrt(D);
double t1 = (-B + sd) / (2 * A);
double t2 = (-B - sd) / (2 * A);
long long llt1 = ceil(min(t1, t2));
long long llt2 = floor(max(t1, t2));
evs.emplace_back(llt1, 0);
evs.emplace_back(llt2, 1);
}
}
sort(evs.begin(), evs.end());
int ans = 0, cnt = 0;
for (int i=0; i<(int)evs.size(); i++) {
auto &[t, rem] = evs[i];
if (t >= 0) ans = max(ans, cnt);
if (rem) {
cnt--;
} else {
cnt++;
}
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int tcs = 1;
// cin >> tcs;
while (tcs--) {
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
508 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
456 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
508 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
456 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
25 ms |
9420 KB |
Output is correct |
24 |
Correct |
25 ms |
9156 KB |
Output is correct |
25 |
Correct |
25 ms |
9420 KB |
Output is correct |
26 |
Correct |
25 ms |
9420 KB |
Output is correct |
27 |
Correct |
27 ms |
9684 KB |
Output is correct |
28 |
Correct |
27 ms |
9420 KB |
Output is correct |
29 |
Correct |
27 ms |
9424 KB |
Output is correct |
30 |
Correct |
27 ms |
9572 KB |
Output is correct |
31 |
Correct |
27 ms |
9428 KB |
Output is correct |
32 |
Correct |
33 ms |
9600 KB |
Output is correct |
33 |
Correct |
33 ms |
9420 KB |
Output is correct |
34 |
Correct |
33 ms |
9416 KB |
Output is correct |
35 |
Correct |
33 ms |
9344 KB |
Output is correct |
36 |
Correct |
34 ms |
9380 KB |
Output is correct |
37 |
Correct |
26 ms |
9208 KB |
Output is correct |
38 |
Correct |
26 ms |
9368 KB |
Output is correct |
39 |
Correct |
27 ms |
9204 KB |
Output is correct |
40 |
Correct |
34 ms |
9172 KB |
Output is correct |
41 |
Correct |
31 ms |
9164 KB |
Output is correct |
42 |
Correct |
26 ms |
9428 KB |
Output is correct |
43 |
Correct |
79 ms |
19252 KB |
Output is correct |
44 |
Correct |
79 ms |
19400 KB |
Output is correct |
45 |
Correct |
74 ms |
19168 KB |
Output is correct |
46 |
Correct |
73 ms |
19144 KB |
Output is correct |
47 |
Correct |
73 ms |
19144 KB |
Output is correct |
48 |
Correct |
66 ms |
18516 KB |
Output is correct |
49 |
Correct |
70 ms |
18632 KB |
Output is correct |
50 |
Correct |
66 ms |
18372 KB |
Output is correct |
51 |
Correct |
66 ms |
18500 KB |
Output is correct |
52 |
Correct |
66 ms |
18376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
508 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
456 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
508 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
456 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
25 ms |
9420 KB |
Output is correct |
24 |
Correct |
25 ms |
9156 KB |
Output is correct |
25 |
Correct |
25 ms |
9420 KB |
Output is correct |
26 |
Correct |
25 ms |
9420 KB |
Output is correct |
27 |
Correct |
27 ms |
9684 KB |
Output is correct |
28 |
Correct |
27 ms |
9420 KB |
Output is correct |
29 |
Correct |
27 ms |
9424 KB |
Output is correct |
30 |
Correct |
27 ms |
9572 KB |
Output is correct |
31 |
Correct |
27 ms |
9428 KB |
Output is correct |
32 |
Correct |
33 ms |
9600 KB |
Output is correct |
33 |
Correct |
33 ms |
9420 KB |
Output is correct |
34 |
Correct |
33 ms |
9416 KB |
Output is correct |
35 |
Correct |
33 ms |
9344 KB |
Output is correct |
36 |
Correct |
34 ms |
9380 KB |
Output is correct |
37 |
Correct |
26 ms |
9208 KB |
Output is correct |
38 |
Correct |
26 ms |
9368 KB |
Output is correct |
39 |
Correct |
27 ms |
9204 KB |
Output is correct |
40 |
Correct |
34 ms |
9172 KB |
Output is correct |
41 |
Correct |
31 ms |
9164 KB |
Output is correct |
42 |
Correct |
26 ms |
9428 KB |
Output is correct |
43 |
Correct |
79 ms |
19252 KB |
Output is correct |
44 |
Correct |
79 ms |
19400 KB |
Output is correct |
45 |
Correct |
74 ms |
19168 KB |
Output is correct |
46 |
Correct |
73 ms |
19144 KB |
Output is correct |
47 |
Correct |
73 ms |
19144 KB |
Output is correct |
48 |
Correct |
66 ms |
18516 KB |
Output is correct |
49 |
Correct |
70 ms |
18632 KB |
Output is correct |
50 |
Correct |
66 ms |
18372 KB |
Output is correct |
51 |
Correct |
66 ms |
18500 KB |
Output is correct |
52 |
Correct |
66 ms |
18376 KB |
Output is correct |
53 |
Correct |
0 ms |
344 KB |
Output is correct |
54 |
Correct |
1 ms |
348 KB |
Output is correct |
55 |
Correct |
1 ms |
468 KB |
Output is correct |
56 |
Correct |
0 ms |
348 KB |
Output is correct |
57 |
Correct |
1 ms |
348 KB |
Output is correct |
58 |
Correct |
1 ms |
344 KB |
Output is correct |
59 |
Correct |
25 ms |
9172 KB |
Output is correct |
60 |
Correct |
31 ms |
9696 KB |
Output is correct |
61 |
Correct |
32 ms |
9736 KB |
Output is correct |
62 |
Correct |
31 ms |
9676 KB |
Output is correct |
63 |
Correct |
35 ms |
9684 KB |
Output is correct |
64 |
Correct |
35 ms |
9708 KB |
Output is correct |
65 |
Correct |
35 ms |
9684 KB |
Output is correct |
66 |
Correct |
36 ms |
9836 KB |
Output is correct |
67 |
Correct |
35 ms |
9676 KB |
Output is correct |
68 |
Correct |
35 ms |
9672 KB |
Output is correct |
69 |
Correct |
36 ms |
9684 KB |
Output is correct |
70 |
Correct |
44 ms |
9684 KB |
Output is correct |
71 |
Correct |
37 ms |
9600 KB |
Output is correct |
72 |
Correct |
35 ms |
9468 KB |
Output is correct |
73 |
Correct |
27 ms |
9172 KB |
Output is correct |
74 |
Correct |
32 ms |
9164 KB |
Output is correct |
75 |
Correct |
28 ms |
9164 KB |
Output is correct |
76 |
Correct |
28 ms |
9420 KB |
Output is correct |
77 |
Correct |
75 ms |
19124 KB |
Output is correct |
78 |
Correct |
78 ms |
19144 KB |
Output is correct |
79 |
Correct |
73 ms |
19140 KB |
Output is correct |
80 |
Correct |
72 ms |
19140 KB |
Output is correct |
81 |
Correct |
73 ms |
19144 KB |
Output is correct |
82 |
Correct |
69 ms |
18732 KB |
Output is correct |
83 |
Correct |
69 ms |
18632 KB |
Output is correct |
84 |
Correct |
69 ms |
18632 KB |
Output is correct |
85 |
Correct |
74 ms |
18628 KB |
Output is correct |
86 |
Correct |
69 ms |
18628 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
508 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
456 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
25 ms |
9420 KB |
Output is correct |
24 |
Correct |
25 ms |
9156 KB |
Output is correct |
25 |
Correct |
25 ms |
9420 KB |
Output is correct |
26 |
Correct |
25 ms |
9420 KB |
Output is correct |
27 |
Correct |
27 ms |
9684 KB |
Output is correct |
28 |
Correct |
27 ms |
9420 KB |
Output is correct |
29 |
Correct |
27 ms |
9424 KB |
Output is correct |
30 |
Correct |
27 ms |
9572 KB |
Output is correct |
31 |
Correct |
27 ms |
9428 KB |
Output is correct |
32 |
Correct |
33 ms |
9600 KB |
Output is correct |
33 |
Correct |
33 ms |
9420 KB |
Output is correct |
34 |
Correct |
33 ms |
9416 KB |
Output is correct |
35 |
Correct |
33 ms |
9344 KB |
Output is correct |
36 |
Correct |
34 ms |
9380 KB |
Output is correct |
37 |
Correct |
26 ms |
9208 KB |
Output is correct |
38 |
Correct |
26 ms |
9368 KB |
Output is correct |
39 |
Correct |
27 ms |
9204 KB |
Output is correct |
40 |
Correct |
34 ms |
9172 KB |
Output is correct |
41 |
Correct |
31 ms |
9164 KB |
Output is correct |
42 |
Correct |
26 ms |
9428 KB |
Output is correct |
43 |
Correct |
79 ms |
19252 KB |
Output is correct |
44 |
Correct |
79 ms |
19400 KB |
Output is correct |
45 |
Correct |
74 ms |
19168 KB |
Output is correct |
46 |
Correct |
73 ms |
19144 KB |
Output is correct |
47 |
Correct |
73 ms |
19144 KB |
Output is correct |
48 |
Correct |
66 ms |
18516 KB |
Output is correct |
49 |
Correct |
70 ms |
18632 KB |
Output is correct |
50 |
Correct |
66 ms |
18372 KB |
Output is correct |
51 |
Correct |
66 ms |
18500 KB |
Output is correct |
52 |
Correct |
66 ms |
18376 KB |
Output is correct |
53 |
Correct |
25 ms |
9172 KB |
Output is correct |
54 |
Correct |
31 ms |
9696 KB |
Output is correct |
55 |
Correct |
32 ms |
9736 KB |
Output is correct |
56 |
Correct |
31 ms |
9676 KB |
Output is correct |
57 |
Correct |
35 ms |
9684 KB |
Output is correct |
58 |
Correct |
35 ms |
9708 KB |
Output is correct |
59 |
Correct |
35 ms |
9684 KB |
Output is correct |
60 |
Correct |
36 ms |
9836 KB |
Output is correct |
61 |
Correct |
35 ms |
9676 KB |
Output is correct |
62 |
Correct |
35 ms |
9672 KB |
Output is correct |
63 |
Correct |
36 ms |
9684 KB |
Output is correct |
64 |
Correct |
44 ms |
9684 KB |
Output is correct |
65 |
Correct |
37 ms |
9600 KB |
Output is correct |
66 |
Correct |
35 ms |
9468 KB |
Output is correct |
67 |
Correct |
27 ms |
9172 KB |
Output is correct |
68 |
Correct |
32 ms |
9164 KB |
Output is correct |
69 |
Correct |
28 ms |
9164 KB |
Output is correct |
70 |
Correct |
28 ms |
9420 KB |
Output is correct |
71 |
Correct |
75 ms |
19124 KB |
Output is correct |
72 |
Correct |
78 ms |
19144 KB |
Output is correct |
73 |
Correct |
73 ms |
19140 KB |
Output is correct |
74 |
Correct |
72 ms |
19140 KB |
Output is correct |
75 |
Correct |
73 ms |
19144 KB |
Output is correct |
76 |
Correct |
69 ms |
18732 KB |
Output is correct |
77 |
Correct |
69 ms |
18632 KB |
Output is correct |
78 |
Correct |
69 ms |
18632 KB |
Output is correct |
79 |
Correct |
74 ms |
18628 KB |
Output is correct |
80 |
Correct |
69 ms |
18628 KB |
Output is correct |
81 |
Correct |
0 ms |
344 KB |
Output is correct |
82 |
Correct |
1 ms |
348 KB |
Output is correct |
83 |
Correct |
1 ms |
468 KB |
Output is correct |
84 |
Correct |
0 ms |
348 KB |
Output is correct |
85 |
Correct |
1 ms |
348 KB |
Output is correct |
86 |
Correct |
1 ms |
344 KB |
Output is correct |
87 |
Incorrect |
42 ms |
11368 KB |
Output isn't correct |
88 |
Halted |
0 ms |
0 KB |
- |