# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1023562 |
2024-07-15T02:31:27 Z |
vjudge1 |
Wish (LMIO19_noras) |
C++17 |
|
86 ms |
16844 KB |
#include <bits/stdc++.h>
using namespace std;
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));
if (llt1 <= llt2) {
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 |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 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 |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 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 |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 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 |
27 ms |
8584 KB |
Output is correct |
24 |
Correct |
25 ms |
8660 KB |
Output is correct |
25 |
Correct |
25 ms |
9676 KB |
Output is correct |
26 |
Correct |
24 ms |
8660 KB |
Output is correct |
27 |
Correct |
25 ms |
5788 KB |
Output is correct |
28 |
Correct |
27 ms |
8084 KB |
Output is correct |
29 |
Correct |
32 ms |
8184 KB |
Output is correct |
30 |
Correct |
27 ms |
9684 KB |
Output is correct |
31 |
Correct |
26 ms |
8848 KB |
Output is correct |
32 |
Correct |
33 ms |
8404 KB |
Output is correct |
33 |
Correct |
33 ms |
9160 KB |
Output is correct |
34 |
Correct |
33 ms |
9428 KB |
Output is correct |
35 |
Correct |
34 ms |
8140 KB |
Output is correct |
36 |
Correct |
33 ms |
7888 KB |
Output is correct |
37 |
Correct |
25 ms |
5580 KB |
Output is correct |
38 |
Correct |
24 ms |
5596 KB |
Output is correct |
39 |
Correct |
25 ms |
5776 KB |
Output is correct |
40 |
Correct |
23 ms |
5592 KB |
Output is correct |
41 |
Correct |
23 ms |
5780 KB |
Output is correct |
42 |
Correct |
26 ms |
5776 KB |
Output is correct |
43 |
Correct |
73 ms |
15296 KB |
Output is correct |
44 |
Correct |
72 ms |
16844 KB |
Output is correct |
45 |
Correct |
71 ms |
16816 KB |
Output is correct |
46 |
Correct |
72 ms |
15556 KB |
Output is correct |
47 |
Correct |
85 ms |
16044 KB |
Output is correct |
48 |
Correct |
65 ms |
16316 KB |
Output is correct |
49 |
Correct |
64 ms |
15292 KB |
Output is correct |
50 |
Correct |
66 ms |
16324 KB |
Output is correct |
51 |
Correct |
68 ms |
15280 KB |
Output is correct |
52 |
Correct |
66 ms |
16072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 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 |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 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 |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 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 |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 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 |
27 ms |
8584 KB |
Output is correct |
24 |
Correct |
25 ms |
8660 KB |
Output is correct |
25 |
Correct |
25 ms |
9676 KB |
Output is correct |
26 |
Correct |
24 ms |
8660 KB |
Output is correct |
27 |
Correct |
25 ms |
5788 KB |
Output is correct |
28 |
Correct |
27 ms |
8084 KB |
Output is correct |
29 |
Correct |
32 ms |
8184 KB |
Output is correct |
30 |
Correct |
27 ms |
9684 KB |
Output is correct |
31 |
Correct |
26 ms |
8848 KB |
Output is correct |
32 |
Correct |
33 ms |
8404 KB |
Output is correct |
33 |
Correct |
33 ms |
9160 KB |
Output is correct |
34 |
Correct |
33 ms |
9428 KB |
Output is correct |
35 |
Correct |
34 ms |
8140 KB |
Output is correct |
36 |
Correct |
33 ms |
7888 KB |
Output is correct |
37 |
Correct |
25 ms |
5580 KB |
Output is correct |
38 |
Correct |
24 ms |
5596 KB |
Output is correct |
39 |
Correct |
25 ms |
5776 KB |
Output is correct |
40 |
Correct |
23 ms |
5592 KB |
Output is correct |
41 |
Correct |
23 ms |
5780 KB |
Output is correct |
42 |
Correct |
26 ms |
5776 KB |
Output is correct |
43 |
Correct |
73 ms |
15296 KB |
Output is correct |
44 |
Correct |
72 ms |
16844 KB |
Output is correct |
45 |
Correct |
71 ms |
16816 KB |
Output is correct |
46 |
Correct |
72 ms |
15556 KB |
Output is correct |
47 |
Correct |
85 ms |
16044 KB |
Output is correct |
48 |
Correct |
65 ms |
16316 KB |
Output is correct |
49 |
Correct |
64 ms |
15292 KB |
Output is correct |
50 |
Correct |
66 ms |
16324 KB |
Output is correct |
51 |
Correct |
68 ms |
15280 KB |
Output is correct |
52 |
Correct |
66 ms |
16072 KB |
Output is correct |
53 |
Correct |
0 ms |
348 KB |
Output is correct |
54 |
Correct |
1 ms |
344 KB |
Output is correct |
55 |
Correct |
1 ms |
344 KB |
Output is correct |
56 |
Correct |
1 ms |
348 KB |
Output is correct |
57 |
Correct |
1 ms |
348 KB |
Output is correct |
58 |
Correct |
1 ms |
348 KB |
Output is correct |
59 |
Correct |
28 ms |
8908 KB |
Output is correct |
60 |
Correct |
32 ms |
8564 KB |
Output is correct |
61 |
Correct |
32 ms |
8140 KB |
Output is correct |
62 |
Correct |
32 ms |
5584 KB |
Output is correct |
63 |
Correct |
37 ms |
8904 KB |
Output is correct |
64 |
Correct |
37 ms |
8904 KB |
Output is correct |
65 |
Correct |
34 ms |
8656 KB |
Output is correct |
66 |
Correct |
37 ms |
7628 KB |
Output is correct |
67 |
Correct |
37 ms |
9428 KB |
Output is correct |
68 |
Correct |
36 ms |
7892 KB |
Output is correct |
69 |
Correct |
37 ms |
8856 KB |
Output is correct |
70 |
Correct |
46 ms |
8652 KB |
Output is correct |
71 |
Correct |
34 ms |
8332 KB |
Output is correct |
72 |
Correct |
43 ms |
8272 KB |
Output is correct |
73 |
Correct |
25 ms |
5584 KB |
Output is correct |
74 |
Correct |
30 ms |
8916 KB |
Output is correct |
75 |
Correct |
27 ms |
8648 KB |
Output is correct |
76 |
Correct |
26 ms |
5772 KB |
Output is correct |
77 |
Correct |
86 ms |
16564 KB |
Output is correct |
78 |
Correct |
78 ms |
15812 KB |
Output is correct |
79 |
Correct |
74 ms |
16840 KB |
Output is correct |
80 |
Correct |
74 ms |
16068 KB |
Output is correct |
81 |
Correct |
75 ms |
15048 KB |
Output is correct |
82 |
Correct |
73 ms |
15552 KB |
Output is correct |
83 |
Correct |
72 ms |
16828 KB |
Output is correct |
84 |
Correct |
74 ms |
16072 KB |
Output is correct |
85 |
Correct |
76 ms |
15544 KB |
Output is correct |
86 |
Correct |
73 ms |
16824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 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 |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 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 |
27 ms |
8584 KB |
Output is correct |
24 |
Correct |
25 ms |
8660 KB |
Output is correct |
25 |
Correct |
25 ms |
9676 KB |
Output is correct |
26 |
Correct |
24 ms |
8660 KB |
Output is correct |
27 |
Correct |
25 ms |
5788 KB |
Output is correct |
28 |
Correct |
27 ms |
8084 KB |
Output is correct |
29 |
Correct |
32 ms |
8184 KB |
Output is correct |
30 |
Correct |
27 ms |
9684 KB |
Output is correct |
31 |
Correct |
26 ms |
8848 KB |
Output is correct |
32 |
Correct |
33 ms |
8404 KB |
Output is correct |
33 |
Correct |
33 ms |
9160 KB |
Output is correct |
34 |
Correct |
33 ms |
9428 KB |
Output is correct |
35 |
Correct |
34 ms |
8140 KB |
Output is correct |
36 |
Correct |
33 ms |
7888 KB |
Output is correct |
37 |
Correct |
25 ms |
5580 KB |
Output is correct |
38 |
Correct |
24 ms |
5596 KB |
Output is correct |
39 |
Correct |
25 ms |
5776 KB |
Output is correct |
40 |
Correct |
23 ms |
5592 KB |
Output is correct |
41 |
Correct |
23 ms |
5780 KB |
Output is correct |
42 |
Correct |
26 ms |
5776 KB |
Output is correct |
43 |
Correct |
73 ms |
15296 KB |
Output is correct |
44 |
Correct |
72 ms |
16844 KB |
Output is correct |
45 |
Correct |
71 ms |
16816 KB |
Output is correct |
46 |
Correct |
72 ms |
15556 KB |
Output is correct |
47 |
Correct |
85 ms |
16044 KB |
Output is correct |
48 |
Correct |
65 ms |
16316 KB |
Output is correct |
49 |
Correct |
64 ms |
15292 KB |
Output is correct |
50 |
Correct |
66 ms |
16324 KB |
Output is correct |
51 |
Correct |
68 ms |
15280 KB |
Output is correct |
52 |
Correct |
66 ms |
16072 KB |
Output is correct |
53 |
Correct |
28 ms |
8908 KB |
Output is correct |
54 |
Correct |
32 ms |
8564 KB |
Output is correct |
55 |
Correct |
32 ms |
8140 KB |
Output is correct |
56 |
Correct |
32 ms |
5584 KB |
Output is correct |
57 |
Correct |
37 ms |
8904 KB |
Output is correct |
58 |
Correct |
37 ms |
8904 KB |
Output is correct |
59 |
Correct |
34 ms |
8656 KB |
Output is correct |
60 |
Correct |
37 ms |
7628 KB |
Output is correct |
61 |
Correct |
37 ms |
9428 KB |
Output is correct |
62 |
Correct |
36 ms |
7892 KB |
Output is correct |
63 |
Correct |
37 ms |
8856 KB |
Output is correct |
64 |
Correct |
46 ms |
8652 KB |
Output is correct |
65 |
Correct |
34 ms |
8332 KB |
Output is correct |
66 |
Correct |
43 ms |
8272 KB |
Output is correct |
67 |
Correct |
25 ms |
5584 KB |
Output is correct |
68 |
Correct |
30 ms |
8916 KB |
Output is correct |
69 |
Correct |
27 ms |
8648 KB |
Output is correct |
70 |
Correct |
26 ms |
5772 KB |
Output is correct |
71 |
Correct |
86 ms |
16564 KB |
Output is correct |
72 |
Correct |
78 ms |
15812 KB |
Output is correct |
73 |
Correct |
74 ms |
16840 KB |
Output is correct |
74 |
Correct |
74 ms |
16068 KB |
Output is correct |
75 |
Correct |
75 ms |
15048 KB |
Output is correct |
76 |
Correct |
73 ms |
15552 KB |
Output is correct |
77 |
Correct |
72 ms |
16828 KB |
Output is correct |
78 |
Correct |
74 ms |
16072 KB |
Output is correct |
79 |
Correct |
76 ms |
15544 KB |
Output is correct |
80 |
Correct |
73 ms |
16824 KB |
Output is correct |
81 |
Correct |
0 ms |
348 KB |
Output is correct |
82 |
Correct |
1 ms |
344 KB |
Output is correct |
83 |
Correct |
1 ms |
344 KB |
Output is correct |
84 |
Correct |
1 ms |
348 KB |
Output is correct |
85 |
Correct |
1 ms |
348 KB |
Output is correct |
86 |
Correct |
1 ms |
348 KB |
Output is correct |
87 |
Incorrect |
42 ms |
9168 KB |
Output isn't correct |
88 |
Halted |
0 ms |
0 KB |
- |