#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, int> pii;
int n, r;
int a[200010], b[200010], dx[200010], dy[200010];
int pref[200010];
vector<pii> v;
long long sq(long long x){
return x * x;
}
bool check(long long dx, long long dy){
return sq(dx) + sq(dy) <= sq(r);
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cin >> n >> r;
for(int i = 1; i <= n; i++){
cin >> a[i] >> b[i] >> dx[i] >> dy[i];
dx[i] -= a[i];
dy[i] -= b[i];
long long A, B, C;
long double D;
A = sq(dx[i]) + sq(dy[i]); B = 2LL * (1LL * a[i] * dx[i] + 1LL * b[i] * dy[i]); C = sq(a[i]) + sq(b[i]) - sq(r);
D = (long double) B*B - (long double) 4 * A * C;
// cerr << mn << " " << mx << "\n";
if(D < 0) continue;
long long mn = ceil((long double) (-B - sqrtl(D)) / (2LL * A)), mx = floor((long double) (-B + sqrtl(D)) / (2LL * A));
bool f1, f2;
for(int off = -10; off <= 10; off++){
if(check(a[i] + 1LL * (mn + off) * dx[i], b[i] + 1LL * (mn + off) * dy[i])){
mn += off; f1 = true;
break;
}
}
for(int off = 10; off >= -10; off--){
if(check(a[i] + 1LL * (mx + off) * dx[i], b[i] + 1LL * (mx + off) * dy[i])){
mx += off; f2 = true;
break;
}
}
if(!f1 || !f2) continue;
if(mx >= 0 && mn <= mx){
// cerr << mn << " " << mx << "\n";
assert(check(a[i] + 1LL * mn * dx[i], b[i] + 1LL * mn * dy[i]));
assert(check(a[i] + 1LL * mx * dx[i], b[i] + 1LL * mx * dy[i]));
v.emplace_back(max(0LL, mn), 1);
v.emplace_back(mx + 1, -1);
}
// for(int k = 0; k <= 20000; k++){
// if(sq(a[i] + 1LL * k * dx[i]) + sq(b[i] + 1LL * k * dy[i]) <= sq(r)) pref[k]++;
// }
}
int ans = 0, cnt = 0;
sort(v.begin(), v.end());
for(int i = 0; i < (int) v.size(); i++){
int j = i;
while(j < (int) v.size() && v[i].first == v[j].first){
cnt += v[j++].second;
}
ans = max(ans, cnt);
i = j - 1;
}
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 |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 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 |
1 ms |
396 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 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 |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 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 |
1 ms |
396 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
59 ms |
5868 KB |
Output is correct |
24 |
Correct |
68 ms |
5868 KB |
Output is correct |
25 |
Correct |
62 ms |
5864 KB |
Output is correct |
26 |
Correct |
70 ms |
5868 KB |
Output is correct |
27 |
Correct |
59 ms |
3948 KB |
Output is correct |
28 |
Correct |
57 ms |
5996 KB |
Output is correct |
29 |
Correct |
59 ms |
5996 KB |
Output is correct |
30 |
Correct |
53 ms |
5996 KB |
Output is correct |
31 |
Correct |
52 ms |
5996 KB |
Output is correct |
32 |
Correct |
65 ms |
5864 KB |
Output is correct |
33 |
Correct |
63 ms |
5868 KB |
Output is correct |
34 |
Correct |
63 ms |
5864 KB |
Output is correct |
35 |
Correct |
64 ms |
5868 KB |
Output is correct |
36 |
Correct |
62 ms |
5868 KB |
Output is correct |
37 |
Correct |
57 ms |
4332 KB |
Output is correct |
38 |
Correct |
54 ms |
4204 KB |
Output is correct |
39 |
Correct |
50 ms |
4080 KB |
Output is correct |
40 |
Correct |
49 ms |
3952 KB |
Output is correct |
41 |
Correct |
50 ms |
4080 KB |
Output is correct |
42 |
Correct |
50 ms |
4080 KB |
Output is correct |
43 |
Correct |
135 ms |
11104 KB |
Output is correct |
44 |
Correct |
134 ms |
11108 KB |
Output is correct |
45 |
Correct |
135 ms |
11012 KB |
Output is correct |
46 |
Correct |
135 ms |
11104 KB |
Output is correct |
47 |
Correct |
134 ms |
11104 KB |
Output is correct |
48 |
Correct |
128 ms |
10976 KB |
Output is correct |
49 |
Correct |
125 ms |
10976 KB |
Output is correct |
50 |
Correct |
130 ms |
10980 KB |
Output is correct |
51 |
Correct |
133 ms |
10980 KB |
Output is correct |
52 |
Correct |
128 ms |
10976 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 |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 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 |
1 ms |
396 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
0 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
512 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 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 |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 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 |
1 ms |
396 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
59 ms |
5868 KB |
Output is correct |
24 |
Correct |
68 ms |
5868 KB |
Output is correct |
25 |
Correct |
62 ms |
5864 KB |
Output is correct |
26 |
Correct |
70 ms |
5868 KB |
Output is correct |
27 |
Correct |
59 ms |
3948 KB |
Output is correct |
28 |
Correct |
57 ms |
5996 KB |
Output is correct |
29 |
Correct |
59 ms |
5996 KB |
Output is correct |
30 |
Correct |
53 ms |
5996 KB |
Output is correct |
31 |
Correct |
52 ms |
5996 KB |
Output is correct |
32 |
Correct |
65 ms |
5864 KB |
Output is correct |
33 |
Correct |
63 ms |
5868 KB |
Output is correct |
34 |
Correct |
63 ms |
5864 KB |
Output is correct |
35 |
Correct |
64 ms |
5868 KB |
Output is correct |
36 |
Correct |
62 ms |
5868 KB |
Output is correct |
37 |
Correct |
57 ms |
4332 KB |
Output is correct |
38 |
Correct |
54 ms |
4204 KB |
Output is correct |
39 |
Correct |
50 ms |
4080 KB |
Output is correct |
40 |
Correct |
49 ms |
3952 KB |
Output is correct |
41 |
Correct |
50 ms |
4080 KB |
Output is correct |
42 |
Correct |
50 ms |
4080 KB |
Output is correct |
43 |
Correct |
135 ms |
11104 KB |
Output is correct |
44 |
Correct |
134 ms |
11108 KB |
Output is correct |
45 |
Correct |
135 ms |
11012 KB |
Output is correct |
46 |
Correct |
135 ms |
11104 KB |
Output is correct |
47 |
Correct |
134 ms |
11104 KB |
Output is correct |
48 |
Correct |
128 ms |
10976 KB |
Output is correct |
49 |
Correct |
125 ms |
10976 KB |
Output is correct |
50 |
Correct |
130 ms |
10980 KB |
Output is correct |
51 |
Correct |
133 ms |
10980 KB |
Output is correct |
52 |
Correct |
128 ms |
10976 KB |
Output is correct |
53 |
Correct |
53 ms |
5864 KB |
Output is correct |
54 |
Correct |
54 ms |
3832 KB |
Output is correct |
55 |
Correct |
62 ms |
3816 KB |
Output is correct |
56 |
Correct |
60 ms |
3944 KB |
Output is correct |
57 |
Correct |
62 ms |
3952 KB |
Output is correct |
58 |
Correct |
65 ms |
3952 KB |
Output is correct |
59 |
Correct |
57 ms |
3824 KB |
Output is correct |
60 |
Correct |
60 ms |
3824 KB |
Output is correct |
61 |
Correct |
57 ms |
3824 KB |
Output is correct |
62 |
Correct |
68 ms |
5868 KB |
Output is correct |
63 |
Correct |
65 ms |
5868 KB |
Output is correct |
64 |
Correct |
65 ms |
5868 KB |
Output is correct |
65 |
Correct |
64 ms |
5868 KB |
Output is correct |
66 |
Correct |
64 ms |
5868 KB |
Output is correct |
67 |
Correct |
67 ms |
4072 KB |
Output is correct |
68 |
Correct |
57 ms |
6380 KB |
Output is correct |
69 |
Correct |
54 ms |
6248 KB |
Output is correct |
70 |
Correct |
51 ms |
3952 KB |
Output is correct |
71 |
Correct |
142 ms |
11360 KB |
Output is correct |
72 |
Correct |
135 ms |
11360 KB |
Output is correct |
73 |
Correct |
128 ms |
11360 KB |
Output is correct |
74 |
Correct |
140 ms |
11360 KB |
Output is correct |
75 |
Correct |
133 ms |
11360 KB |
Output is correct |
76 |
Correct |
132 ms |
11276 KB |
Output is correct |
77 |
Correct |
126 ms |
11108 KB |
Output is correct |
78 |
Correct |
131 ms |
11100 KB |
Output is correct |
79 |
Correct |
127 ms |
11104 KB |
Output is correct |
80 |
Correct |
131 ms |
11276 KB |
Output is correct |
81 |
Correct |
0 ms |
384 KB |
Output is correct |
82 |
Correct |
1 ms |
384 KB |
Output is correct |
83 |
Correct |
1 ms |
512 KB |
Output is correct |
84 |
Correct |
1 ms |
384 KB |
Output is correct |
85 |
Correct |
1 ms |
384 KB |
Output is correct |
86 |
Correct |
1 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 |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 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 |
1 ms |
396 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
59 ms |
5868 KB |
Output is correct |
24 |
Correct |
68 ms |
5868 KB |
Output is correct |
25 |
Correct |
62 ms |
5864 KB |
Output is correct |
26 |
Correct |
70 ms |
5868 KB |
Output is correct |
27 |
Correct |
59 ms |
3948 KB |
Output is correct |
28 |
Correct |
57 ms |
5996 KB |
Output is correct |
29 |
Correct |
59 ms |
5996 KB |
Output is correct |
30 |
Correct |
53 ms |
5996 KB |
Output is correct |
31 |
Correct |
52 ms |
5996 KB |
Output is correct |
32 |
Correct |
65 ms |
5864 KB |
Output is correct |
33 |
Correct |
63 ms |
5868 KB |
Output is correct |
34 |
Correct |
63 ms |
5864 KB |
Output is correct |
35 |
Correct |
64 ms |
5868 KB |
Output is correct |
36 |
Correct |
62 ms |
5868 KB |
Output is correct |
37 |
Correct |
57 ms |
4332 KB |
Output is correct |
38 |
Correct |
54 ms |
4204 KB |
Output is correct |
39 |
Correct |
50 ms |
4080 KB |
Output is correct |
40 |
Correct |
49 ms |
3952 KB |
Output is correct |
41 |
Correct |
50 ms |
4080 KB |
Output is correct |
42 |
Correct |
50 ms |
4080 KB |
Output is correct |
43 |
Correct |
135 ms |
11104 KB |
Output is correct |
44 |
Correct |
134 ms |
11108 KB |
Output is correct |
45 |
Correct |
135 ms |
11012 KB |
Output is correct |
46 |
Correct |
135 ms |
11104 KB |
Output is correct |
47 |
Correct |
134 ms |
11104 KB |
Output is correct |
48 |
Correct |
128 ms |
10976 KB |
Output is correct |
49 |
Correct |
125 ms |
10976 KB |
Output is correct |
50 |
Correct |
130 ms |
10980 KB |
Output is correct |
51 |
Correct |
133 ms |
10980 KB |
Output is correct |
52 |
Correct |
128 ms |
10976 KB |
Output is correct |
53 |
Correct |
53 ms |
5864 KB |
Output is correct |
54 |
Correct |
54 ms |
3832 KB |
Output is correct |
55 |
Correct |
62 ms |
3816 KB |
Output is correct |
56 |
Correct |
60 ms |
3944 KB |
Output is correct |
57 |
Correct |
62 ms |
3952 KB |
Output is correct |
58 |
Correct |
65 ms |
3952 KB |
Output is correct |
59 |
Correct |
57 ms |
3824 KB |
Output is correct |
60 |
Correct |
60 ms |
3824 KB |
Output is correct |
61 |
Correct |
57 ms |
3824 KB |
Output is correct |
62 |
Correct |
68 ms |
5868 KB |
Output is correct |
63 |
Correct |
65 ms |
5868 KB |
Output is correct |
64 |
Correct |
65 ms |
5868 KB |
Output is correct |
65 |
Correct |
64 ms |
5868 KB |
Output is correct |
66 |
Correct |
64 ms |
5868 KB |
Output is correct |
67 |
Correct |
67 ms |
4072 KB |
Output is correct |
68 |
Correct |
57 ms |
6380 KB |
Output is correct |
69 |
Correct |
54 ms |
6248 KB |
Output is correct |
70 |
Correct |
51 ms |
3952 KB |
Output is correct |
71 |
Correct |
142 ms |
11360 KB |
Output is correct |
72 |
Correct |
135 ms |
11360 KB |
Output is correct |
73 |
Correct |
128 ms |
11360 KB |
Output is correct |
74 |
Correct |
140 ms |
11360 KB |
Output is correct |
75 |
Correct |
133 ms |
11360 KB |
Output is correct |
76 |
Correct |
132 ms |
11276 KB |
Output is correct |
77 |
Correct |
126 ms |
11108 KB |
Output is correct |
78 |
Correct |
131 ms |
11100 KB |
Output is correct |
79 |
Correct |
127 ms |
11104 KB |
Output is correct |
80 |
Correct |
131 ms |
11276 KB |
Output is correct |
81 |
Correct |
74 ms |
4036 KB |
Output is correct |
82 |
Correct |
74 ms |
3948 KB |
Output is correct |
83 |
Correct |
75 ms |
6256 KB |
Output is correct |
84 |
Correct |
75 ms |
6384 KB |
Output is correct |
85 |
Correct |
76 ms |
6256 KB |
Output is correct |
86 |
Correct |
73 ms |
6256 KB |
Output is correct |
87 |
Correct |
74 ms |
6256 KB |
Output is correct |
88 |
Correct |
72 ms |
6256 KB |
Output is correct |
89 |
Correct |
75 ms |
6348 KB |
Output is correct |
90 |
Correct |
75 ms |
6252 KB |
Output is correct |
91 |
Correct |
65 ms |
7404 KB |
Output is correct |
92 |
Correct |
64 ms |
7400 KB |
Output is correct |
93 |
Correct |
69 ms |
7540 KB |
Output is correct |
94 |
Correct |
67 ms |
7400 KB |
Output is correct |
95 |
Correct |
63 ms |
7400 KB |
Output is correct |
96 |
Correct |
63 ms |
7432 KB |
Output is correct |
97 |
Correct |
64 ms |
7404 KB |
Output is correct |
98 |
Correct |
68 ms |
7400 KB |
Output is correct |
99 |
Correct |
64 ms |
7400 KB |
Output is correct |
100 |
Correct |
64 ms |
7504 KB |
Output is correct |
101 |
Correct |
0 ms |
384 KB |
Output is correct |
102 |
Correct |
1 ms |
384 KB |
Output is correct |
103 |
Correct |
1 ms |
512 KB |
Output is correct |
104 |
Correct |
1 ms |
384 KB |
Output is correct |
105 |
Correct |
1 ms |
384 KB |
Output is correct |
106 |
Correct |
1 ms |
384 KB |
Output is correct |