#include <bits/stdc++.h>
using namespace std;
template<class T, class U>
void ckmin(T &a, U b)
{
if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
if (a < b) a = b;
}
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
typedef __int128_t ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef pair<pll, pll> ppp;
const int MAXN = 200013;
int N;
ll R;
int ans;
map<ll, int> pref;
ll fdiv(ll a, ll b)
{
return a / b - (a % b < 0);
}
ll cdiv(ll a, ll b)
{
return a / b + (a % b > 0);
}
ll getsqrt(ll x)
{
ll lo = 0, hi = 1e18;
while(hi > lo)
{
ll mid = (hi + lo + 1) >> 1;
if (mid * mid > x) hi = mid - 1;
else lo = mid;
}
return lo;
}
int32_t main()
{
cout << fixed << setprecision(12);
cerr << fixed << setprecision(4);
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> N;
long long rr; cin >> rr; R = rr;
FOR(i, 0, N)
{
long long A, B, C, D;
cin >> A >> B >> C >> D;
ll a, b, c, d;
a = A; b = B; c = C; d = D;
c -= a; d -= b;
ll r = c * c + d * d;
ll s = 2 * b * d + 2 * a * c;
ll t = a * a + b * b - R * R;
// cerr << r << ' ' << s << ' ' << t << endl;
if (s * s - 4 * r * t < 0) continue;
ll sq = getsqrt(s * s - 4 * r * t);
// cerr << -s-sq << ' ' << -s + sq << ' ' << 2 * r << endl;
ll lo = cdiv(-s - sq, 2 * r), hi = fdiv(-s + sq, 2 * r);
// cerr << lo << '@' << hi << endl;
ckmax(lo, 0);
if (lo > hi) continue;
// cerr << lo << ',' << hi << endl;
pref[lo]++; pref[hi + 1]--;
}
if (pref.empty())
{
cout << "0\n";
return 0;
}
for (auto it = next(pref.begin()); it != pref.end(); it++)
{
it -> se += (prev(it)) -> se;
}
for (auto p : pref)
{
ckmax(ans, p.se);
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 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 |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
6 ms |
384 KB |
Output is correct |
17 |
Correct |
6 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 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 |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
6 ms |
384 KB |
Output is correct |
17 |
Correct |
6 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
75 ms |
384 KB |
Output is correct |
24 |
Correct |
74 ms |
384 KB |
Output is correct |
25 |
Correct |
74 ms |
384 KB |
Output is correct |
26 |
Correct |
74 ms |
384 KB |
Output is correct |
27 |
Correct |
78 ms |
384 KB |
Output is correct |
28 |
Correct |
74 ms |
384 KB |
Output is correct |
29 |
Correct |
73 ms |
384 KB |
Output is correct |
30 |
Correct |
73 ms |
512 KB |
Output is correct |
31 |
Correct |
74 ms |
384 KB |
Output is correct |
32 |
Correct |
89 ms |
384 KB |
Output is correct |
33 |
Correct |
89 ms |
384 KB |
Output is correct |
34 |
Correct |
93 ms |
384 KB |
Output is correct |
35 |
Correct |
92 ms |
384 KB |
Output is correct |
36 |
Correct |
92 ms |
384 KB |
Output is correct |
37 |
Correct |
75 ms |
384 KB |
Output is correct |
38 |
Correct |
75 ms |
384 KB |
Output is correct |
39 |
Correct |
74 ms |
384 KB |
Output is correct |
40 |
Correct |
75 ms |
384 KB |
Output is correct |
41 |
Correct |
75 ms |
384 KB |
Output is correct |
42 |
Correct |
77 ms |
384 KB |
Output is correct |
43 |
Correct |
224 ms |
1912 KB |
Output is correct |
44 |
Correct |
218 ms |
1912 KB |
Output is correct |
45 |
Correct |
222 ms |
1912 KB |
Output is correct |
46 |
Correct |
228 ms |
1912 KB |
Output is correct |
47 |
Correct |
227 ms |
1912 KB |
Output is correct |
48 |
Correct |
176 ms |
384 KB |
Output is correct |
49 |
Correct |
172 ms |
384 KB |
Output is correct |
50 |
Correct |
176 ms |
384 KB |
Output is correct |
51 |
Correct |
181 ms |
384 KB |
Output is correct |
52 |
Correct |
176 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 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 |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
6 ms |
384 KB |
Output is correct |
17 |
Correct |
6 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
6 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
512 KB |
Output is correct |
27 |
Correct |
5 ms |
512 KB |
Output is correct |
28 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 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 |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
6 ms |
384 KB |
Output is correct |
17 |
Correct |
6 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
75 ms |
384 KB |
Output is correct |
24 |
Correct |
74 ms |
384 KB |
Output is correct |
25 |
Correct |
74 ms |
384 KB |
Output is correct |
26 |
Correct |
74 ms |
384 KB |
Output is correct |
27 |
Correct |
78 ms |
384 KB |
Output is correct |
28 |
Correct |
74 ms |
384 KB |
Output is correct |
29 |
Correct |
73 ms |
384 KB |
Output is correct |
30 |
Correct |
73 ms |
512 KB |
Output is correct |
31 |
Correct |
74 ms |
384 KB |
Output is correct |
32 |
Correct |
89 ms |
384 KB |
Output is correct |
33 |
Correct |
89 ms |
384 KB |
Output is correct |
34 |
Correct |
93 ms |
384 KB |
Output is correct |
35 |
Correct |
92 ms |
384 KB |
Output is correct |
36 |
Correct |
92 ms |
384 KB |
Output is correct |
37 |
Correct |
75 ms |
384 KB |
Output is correct |
38 |
Correct |
75 ms |
384 KB |
Output is correct |
39 |
Correct |
74 ms |
384 KB |
Output is correct |
40 |
Correct |
75 ms |
384 KB |
Output is correct |
41 |
Correct |
75 ms |
384 KB |
Output is correct |
42 |
Correct |
77 ms |
384 KB |
Output is correct |
43 |
Correct |
224 ms |
1912 KB |
Output is correct |
44 |
Correct |
218 ms |
1912 KB |
Output is correct |
45 |
Correct |
222 ms |
1912 KB |
Output is correct |
46 |
Correct |
228 ms |
1912 KB |
Output is correct |
47 |
Correct |
227 ms |
1912 KB |
Output is correct |
48 |
Correct |
176 ms |
384 KB |
Output is correct |
49 |
Correct |
172 ms |
384 KB |
Output is correct |
50 |
Correct |
176 ms |
384 KB |
Output is correct |
51 |
Correct |
181 ms |
384 KB |
Output is correct |
52 |
Correct |
176 ms |
384 KB |
Output is correct |
53 |
Correct |
74 ms |
384 KB |
Output is correct |
54 |
Correct |
80 ms |
384 KB |
Output is correct |
55 |
Correct |
81 ms |
384 KB |
Output is correct |
56 |
Correct |
79 ms |
384 KB |
Output is correct |
57 |
Correct |
87 ms |
1016 KB |
Output is correct |
58 |
Correct |
89 ms |
1016 KB |
Output is correct |
59 |
Correct |
89 ms |
1016 KB |
Output is correct |
60 |
Correct |
89 ms |
1016 KB |
Output is correct |
61 |
Correct |
86 ms |
1016 KB |
Output is correct |
62 |
Correct |
95 ms |
512 KB |
Output is correct |
63 |
Correct |
97 ms |
512 KB |
Output is correct |
64 |
Correct |
92 ms |
512 KB |
Output is correct |
65 |
Correct |
94 ms |
512 KB |
Output is correct |
66 |
Correct |
93 ms |
512 KB |
Output is correct |
67 |
Correct |
76 ms |
384 KB |
Output is correct |
68 |
Correct |
75 ms |
384 KB |
Output is correct |
69 |
Correct |
76 ms |
384 KB |
Output is correct |
70 |
Correct |
76 ms |
384 KB |
Output is correct |
71 |
Correct |
214 ms |
1912 KB |
Output is correct |
72 |
Correct |
215 ms |
1912 KB |
Output is correct |
73 |
Correct |
213 ms |
1912 KB |
Output is correct |
74 |
Correct |
213 ms |
1912 KB |
Output is correct |
75 |
Correct |
209 ms |
1912 KB |
Output is correct |
76 |
Correct |
181 ms |
512 KB |
Output is correct |
77 |
Correct |
189 ms |
512 KB |
Output is correct |
78 |
Correct |
183 ms |
512 KB |
Output is correct |
79 |
Correct |
182 ms |
512 KB |
Output is correct |
80 |
Correct |
183 ms |
512 KB |
Output is correct |
81 |
Correct |
5 ms |
384 KB |
Output is correct |
82 |
Correct |
5 ms |
384 KB |
Output is correct |
83 |
Correct |
6 ms |
384 KB |
Output is correct |
84 |
Correct |
5 ms |
512 KB |
Output is correct |
85 |
Correct |
5 ms |
512 KB |
Output is correct |
86 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 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 |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
6 ms |
384 KB |
Output is correct |
17 |
Correct |
6 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
75 ms |
384 KB |
Output is correct |
24 |
Correct |
74 ms |
384 KB |
Output is correct |
25 |
Correct |
74 ms |
384 KB |
Output is correct |
26 |
Correct |
74 ms |
384 KB |
Output is correct |
27 |
Correct |
78 ms |
384 KB |
Output is correct |
28 |
Correct |
74 ms |
384 KB |
Output is correct |
29 |
Correct |
73 ms |
384 KB |
Output is correct |
30 |
Correct |
73 ms |
512 KB |
Output is correct |
31 |
Correct |
74 ms |
384 KB |
Output is correct |
32 |
Correct |
89 ms |
384 KB |
Output is correct |
33 |
Correct |
89 ms |
384 KB |
Output is correct |
34 |
Correct |
93 ms |
384 KB |
Output is correct |
35 |
Correct |
92 ms |
384 KB |
Output is correct |
36 |
Correct |
92 ms |
384 KB |
Output is correct |
37 |
Correct |
75 ms |
384 KB |
Output is correct |
38 |
Correct |
75 ms |
384 KB |
Output is correct |
39 |
Correct |
74 ms |
384 KB |
Output is correct |
40 |
Correct |
75 ms |
384 KB |
Output is correct |
41 |
Correct |
75 ms |
384 KB |
Output is correct |
42 |
Correct |
77 ms |
384 KB |
Output is correct |
43 |
Correct |
224 ms |
1912 KB |
Output is correct |
44 |
Correct |
218 ms |
1912 KB |
Output is correct |
45 |
Correct |
222 ms |
1912 KB |
Output is correct |
46 |
Correct |
228 ms |
1912 KB |
Output is correct |
47 |
Correct |
227 ms |
1912 KB |
Output is correct |
48 |
Correct |
176 ms |
384 KB |
Output is correct |
49 |
Correct |
172 ms |
384 KB |
Output is correct |
50 |
Correct |
176 ms |
384 KB |
Output is correct |
51 |
Correct |
181 ms |
384 KB |
Output is correct |
52 |
Correct |
176 ms |
384 KB |
Output is correct |
53 |
Correct |
74 ms |
384 KB |
Output is correct |
54 |
Correct |
80 ms |
384 KB |
Output is correct |
55 |
Correct |
81 ms |
384 KB |
Output is correct |
56 |
Correct |
79 ms |
384 KB |
Output is correct |
57 |
Correct |
87 ms |
1016 KB |
Output is correct |
58 |
Correct |
89 ms |
1016 KB |
Output is correct |
59 |
Correct |
89 ms |
1016 KB |
Output is correct |
60 |
Correct |
89 ms |
1016 KB |
Output is correct |
61 |
Correct |
86 ms |
1016 KB |
Output is correct |
62 |
Correct |
95 ms |
512 KB |
Output is correct |
63 |
Correct |
97 ms |
512 KB |
Output is correct |
64 |
Correct |
92 ms |
512 KB |
Output is correct |
65 |
Correct |
94 ms |
512 KB |
Output is correct |
66 |
Correct |
93 ms |
512 KB |
Output is correct |
67 |
Correct |
76 ms |
384 KB |
Output is correct |
68 |
Correct |
75 ms |
384 KB |
Output is correct |
69 |
Correct |
76 ms |
384 KB |
Output is correct |
70 |
Correct |
76 ms |
384 KB |
Output is correct |
71 |
Correct |
214 ms |
1912 KB |
Output is correct |
72 |
Correct |
215 ms |
1912 KB |
Output is correct |
73 |
Correct |
213 ms |
1912 KB |
Output is correct |
74 |
Correct |
213 ms |
1912 KB |
Output is correct |
75 |
Correct |
209 ms |
1912 KB |
Output is correct |
76 |
Correct |
181 ms |
512 KB |
Output is correct |
77 |
Correct |
189 ms |
512 KB |
Output is correct |
78 |
Correct |
183 ms |
512 KB |
Output is correct |
79 |
Correct |
182 ms |
512 KB |
Output is correct |
80 |
Correct |
183 ms |
512 KB |
Output is correct |
81 |
Correct |
141 ms |
6520 KB |
Output is correct |
82 |
Correct |
142 ms |
9336 KB |
Output is correct |
83 |
Correct |
137 ms |
8060 KB |
Output is correct |
84 |
Correct |
132 ms |
6648 KB |
Output is correct |
85 |
Correct |
124 ms |
5752 KB |
Output is correct |
86 |
Correct |
141 ms |
10232 KB |
Output is correct |
87 |
Correct |
143 ms |
10232 KB |
Output is correct |
88 |
Correct |
139 ms |
10232 KB |
Output is correct |
89 |
Correct |
144 ms |
10232 KB |
Output is correct |
90 |
Correct |
138 ms |
10232 KB |
Output is correct |
91 |
Correct |
85 ms |
2808 KB |
Output is correct |
92 |
Correct |
87 ms |
2680 KB |
Output is correct |
93 |
Correct |
86 ms |
2808 KB |
Output is correct |
94 |
Correct |
87 ms |
2808 KB |
Output is correct |
95 |
Correct |
85 ms |
2680 KB |
Output is correct |
96 |
Correct |
86 ms |
2680 KB |
Output is correct |
97 |
Correct |
88 ms |
2808 KB |
Output is correct |
98 |
Correct |
85 ms |
2680 KB |
Output is correct |
99 |
Correct |
88 ms |
2808 KB |
Output is correct |
100 |
Correct |
84 ms |
2684 KB |
Output is correct |
101 |
Correct |
5 ms |
384 KB |
Output is correct |
102 |
Correct |
5 ms |
384 KB |
Output is correct |
103 |
Correct |
6 ms |
384 KB |
Output is correct |
104 |
Correct |
5 ms |
512 KB |
Output is correct |
105 |
Correct |
5 ms |
512 KB |
Output is correct |
106 |
Correct |
5 ms |
384 KB |
Output is correct |