# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1023558 |
2024-07-15T02:27:01 Z |
vjudge1 |
Wish (LMIO19_noras) |
C++17 |
|
83 ms |
15048 KB |
#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) {
long double sd = sqrt(D);
long double t1 = (-B + sd) / (2 * A);
long 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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 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 |
540 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 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 |
540 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 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 |
28 ms |
7712 KB |
Output is correct |
24 |
Correct |
28 ms |
7828 KB |
Output is correct |
25 |
Correct |
28 ms |
7632 KB |
Output is correct |
26 |
Correct |
28 ms |
7636 KB |
Output is correct |
27 |
Correct |
30 ms |
7636 KB |
Output is correct |
28 |
Correct |
28 ms |
7816 KB |
Output is correct |
29 |
Correct |
28 ms |
7636 KB |
Output is correct |
30 |
Correct |
29 ms |
7824 KB |
Output is correct |
31 |
Correct |
29 ms |
7636 KB |
Output is correct |
32 |
Correct |
35 ms |
7624 KB |
Output is correct |
33 |
Correct |
35 ms |
7632 KB |
Output is correct |
34 |
Correct |
35 ms |
7624 KB |
Output is correct |
35 |
Correct |
34 ms |
7628 KB |
Output is correct |
36 |
Correct |
35 ms |
7624 KB |
Output is correct |
37 |
Correct |
29 ms |
7776 KB |
Output is correct |
38 |
Correct |
28 ms |
7648 KB |
Output is correct |
39 |
Correct |
27 ms |
7624 KB |
Output is correct |
40 |
Correct |
28 ms |
7632 KB |
Output is correct |
41 |
Correct |
28 ms |
7632 KB |
Output is correct |
42 |
Correct |
30 ms |
7824 KB |
Output is correct |
43 |
Correct |
81 ms |
15044 KB |
Output is correct |
44 |
Correct |
76 ms |
15048 KB |
Output is correct |
45 |
Correct |
83 ms |
15048 KB |
Output is correct |
46 |
Correct |
76 ms |
15044 KB |
Output is correct |
47 |
Correct |
75 ms |
15032 KB |
Output is correct |
48 |
Correct |
69 ms |
15044 KB |
Output is correct |
49 |
Correct |
70 ms |
15044 KB |
Output is correct |
50 |
Correct |
81 ms |
15048 KB |
Output is correct |
51 |
Correct |
69 ms |
14940 KB |
Output is correct |
52 |
Correct |
69 ms |
15048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 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 |
540 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 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 |
540 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 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 |
28 ms |
7712 KB |
Output is correct |
24 |
Correct |
28 ms |
7828 KB |
Output is correct |
25 |
Correct |
28 ms |
7632 KB |
Output is correct |
26 |
Correct |
28 ms |
7636 KB |
Output is correct |
27 |
Correct |
30 ms |
7636 KB |
Output is correct |
28 |
Correct |
28 ms |
7816 KB |
Output is correct |
29 |
Correct |
28 ms |
7636 KB |
Output is correct |
30 |
Correct |
29 ms |
7824 KB |
Output is correct |
31 |
Correct |
29 ms |
7636 KB |
Output is correct |
32 |
Correct |
35 ms |
7624 KB |
Output is correct |
33 |
Correct |
35 ms |
7632 KB |
Output is correct |
34 |
Correct |
35 ms |
7624 KB |
Output is correct |
35 |
Correct |
34 ms |
7628 KB |
Output is correct |
36 |
Correct |
35 ms |
7624 KB |
Output is correct |
37 |
Correct |
29 ms |
7776 KB |
Output is correct |
38 |
Correct |
28 ms |
7648 KB |
Output is correct |
39 |
Correct |
27 ms |
7624 KB |
Output is correct |
40 |
Correct |
28 ms |
7632 KB |
Output is correct |
41 |
Correct |
28 ms |
7632 KB |
Output is correct |
42 |
Correct |
30 ms |
7824 KB |
Output is correct |
43 |
Correct |
81 ms |
15044 KB |
Output is correct |
44 |
Correct |
76 ms |
15048 KB |
Output is correct |
45 |
Correct |
83 ms |
15048 KB |
Output is correct |
46 |
Correct |
76 ms |
15044 KB |
Output is correct |
47 |
Correct |
75 ms |
15032 KB |
Output is correct |
48 |
Correct |
69 ms |
15044 KB |
Output is correct |
49 |
Correct |
70 ms |
15044 KB |
Output is correct |
50 |
Correct |
81 ms |
15048 KB |
Output is correct |
51 |
Correct |
69 ms |
14940 KB |
Output is correct |
52 |
Correct |
69 ms |
15048 KB |
Output is correct |
53 |
Correct |
1 ms |
348 KB |
Output is correct |
54 |
Correct |
1 ms |
348 KB |
Output is correct |
55 |
Correct |
1 ms |
348 KB |
Output is correct |
56 |
Correct |
1 ms |
348 KB |
Output is correct |
57 |
Correct |
0 ms |
348 KB |
Output is correct |
58 |
Correct |
1 ms |
348 KB |
Output is correct |
59 |
Correct |
28 ms |
7628 KB |
Output is correct |
60 |
Correct |
33 ms |
7624 KB |
Output is correct |
61 |
Correct |
33 ms |
7636 KB |
Output is correct |
62 |
Correct |
32 ms |
7624 KB |
Output is correct |
63 |
Correct |
39 ms |
7628 KB |
Output is correct |
64 |
Correct |
38 ms |
7624 KB |
Output is correct |
65 |
Correct |
40 ms |
7624 KB |
Output is correct |
66 |
Correct |
37 ms |
7628 KB |
Output is correct |
67 |
Correct |
37 ms |
7632 KB |
Output is correct |
68 |
Correct |
37 ms |
7832 KB |
Output is correct |
69 |
Correct |
37 ms |
7636 KB |
Output is correct |
70 |
Correct |
36 ms |
7632 KB |
Output is correct |
71 |
Correct |
34 ms |
7632 KB |
Output is correct |
72 |
Correct |
34 ms |
7760 KB |
Output is correct |
73 |
Correct |
27 ms |
7636 KB |
Output is correct |
74 |
Correct |
27 ms |
7828 KB |
Output is correct |
75 |
Correct |
27 ms |
7628 KB |
Output is correct |
76 |
Correct |
27 ms |
7628 KB |
Output is correct |
77 |
Correct |
72 ms |
15044 KB |
Output is correct |
78 |
Correct |
72 ms |
14976 KB |
Output is correct |
79 |
Correct |
74 ms |
15044 KB |
Output is correct |
80 |
Correct |
72 ms |
15036 KB |
Output is correct |
81 |
Correct |
73 ms |
15044 KB |
Output is correct |
82 |
Correct |
71 ms |
15048 KB |
Output is correct |
83 |
Correct |
70 ms |
15048 KB |
Output is correct |
84 |
Correct |
69 ms |
15036 KB |
Output is correct |
85 |
Correct |
68 ms |
15040 KB |
Output is correct |
86 |
Correct |
72 ms |
15048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 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 |
540 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 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 |
28 ms |
7712 KB |
Output is correct |
24 |
Correct |
28 ms |
7828 KB |
Output is correct |
25 |
Correct |
28 ms |
7632 KB |
Output is correct |
26 |
Correct |
28 ms |
7636 KB |
Output is correct |
27 |
Correct |
30 ms |
7636 KB |
Output is correct |
28 |
Correct |
28 ms |
7816 KB |
Output is correct |
29 |
Correct |
28 ms |
7636 KB |
Output is correct |
30 |
Correct |
29 ms |
7824 KB |
Output is correct |
31 |
Correct |
29 ms |
7636 KB |
Output is correct |
32 |
Correct |
35 ms |
7624 KB |
Output is correct |
33 |
Correct |
35 ms |
7632 KB |
Output is correct |
34 |
Correct |
35 ms |
7624 KB |
Output is correct |
35 |
Correct |
34 ms |
7628 KB |
Output is correct |
36 |
Correct |
35 ms |
7624 KB |
Output is correct |
37 |
Correct |
29 ms |
7776 KB |
Output is correct |
38 |
Correct |
28 ms |
7648 KB |
Output is correct |
39 |
Correct |
27 ms |
7624 KB |
Output is correct |
40 |
Correct |
28 ms |
7632 KB |
Output is correct |
41 |
Correct |
28 ms |
7632 KB |
Output is correct |
42 |
Correct |
30 ms |
7824 KB |
Output is correct |
43 |
Correct |
81 ms |
15044 KB |
Output is correct |
44 |
Correct |
76 ms |
15048 KB |
Output is correct |
45 |
Correct |
83 ms |
15048 KB |
Output is correct |
46 |
Correct |
76 ms |
15044 KB |
Output is correct |
47 |
Correct |
75 ms |
15032 KB |
Output is correct |
48 |
Correct |
69 ms |
15044 KB |
Output is correct |
49 |
Correct |
70 ms |
15044 KB |
Output is correct |
50 |
Correct |
81 ms |
15048 KB |
Output is correct |
51 |
Correct |
69 ms |
14940 KB |
Output is correct |
52 |
Correct |
69 ms |
15048 KB |
Output is correct |
53 |
Correct |
28 ms |
7628 KB |
Output is correct |
54 |
Correct |
33 ms |
7624 KB |
Output is correct |
55 |
Correct |
33 ms |
7636 KB |
Output is correct |
56 |
Correct |
32 ms |
7624 KB |
Output is correct |
57 |
Correct |
39 ms |
7628 KB |
Output is correct |
58 |
Correct |
38 ms |
7624 KB |
Output is correct |
59 |
Correct |
40 ms |
7624 KB |
Output is correct |
60 |
Correct |
37 ms |
7628 KB |
Output is correct |
61 |
Correct |
37 ms |
7632 KB |
Output is correct |
62 |
Correct |
37 ms |
7832 KB |
Output is correct |
63 |
Correct |
37 ms |
7636 KB |
Output is correct |
64 |
Correct |
36 ms |
7632 KB |
Output is correct |
65 |
Correct |
34 ms |
7632 KB |
Output is correct |
66 |
Correct |
34 ms |
7760 KB |
Output is correct |
67 |
Correct |
27 ms |
7636 KB |
Output is correct |
68 |
Correct |
27 ms |
7828 KB |
Output is correct |
69 |
Correct |
27 ms |
7628 KB |
Output is correct |
70 |
Correct |
27 ms |
7628 KB |
Output is correct |
71 |
Correct |
72 ms |
15044 KB |
Output is correct |
72 |
Correct |
72 ms |
14976 KB |
Output is correct |
73 |
Correct |
74 ms |
15044 KB |
Output is correct |
74 |
Correct |
72 ms |
15036 KB |
Output is correct |
75 |
Correct |
73 ms |
15044 KB |
Output is correct |
76 |
Correct |
71 ms |
15048 KB |
Output is correct |
77 |
Correct |
70 ms |
15048 KB |
Output is correct |
78 |
Correct |
69 ms |
15036 KB |
Output is correct |
79 |
Correct |
68 ms |
15040 KB |
Output is correct |
80 |
Correct |
72 ms |
15048 KB |
Output is correct |
81 |
Correct |
1 ms |
348 KB |
Output is correct |
82 |
Correct |
1 ms |
348 KB |
Output is correct |
83 |
Correct |
1 ms |
348 KB |
Output is correct |
84 |
Correct |
1 ms |
348 KB |
Output is correct |
85 |
Correct |
0 ms |
348 KB |
Output is correct |
86 |
Correct |
1 ms |
348 KB |
Output is correct |
87 |
Incorrect |
39 ms |
7628 KB |
Output isn't correct |
88 |
Halted |
0 ms |
0 KB |
- |