#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6+6;
int n, R, a[N], b[N], c[N], d[N];
map<int, int> f;
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> R;
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i] >> d[i];
int x = c[i]-a[i];
int y = d[i]-b[i];
int l = 0;
int r = 1e9;
while (l < r) {
int mid = (l+r)/2;
bool in1 = (abs(a[i] + x*mid) + abs(b[i] + y*mid)) <= R;
bool in2 = (abs(a[i] + x*(mid+1)) + abs(b[i] + y*(mid+1))) <= R;
if (in1 && in2) r = mid;
else if (in1 && !in2) r = mid;
else if (!in1 && in2) l = r = mid+1;
else {
if (abs(a[i] + x*mid) + abs(b[i] + y*mid) <=
abs(a[i] + x*(mid+1)) + abs(b[i] + y*(mid+1))) {
r = mid;
}
else {
l = mid+1;
}
}
}
int fst = l;
l = 0;
r = 1e9;
while (l < r) {
int mid = (l+r)/2;
bool in1 = (abs(a[i] + x*mid) + abs(b[i] + y*mid)) <= R;
bool in2 = (abs(a[i] + x*(mid+1)) + abs(b[i] + y*(mid+1))) <= R;
if (in1 && in2) l = mid+1;
else if (in1 && !in2) l = r = mid;
else if (!in1 && in2) l = mid+1;
else {
if (abs(a[i] + x*mid) + abs(b[i] + y*mid) <
abs(a[i] + x*(mid+1)) + abs(b[i] + y*(mid+1))) {
r = mid;
}
else {
l = mid+1;
}
}
}
int lst = l;
bool in1 = (abs(a[i] + x*fst) + abs(b[i] + y*fst)) <= R;
if (!in1) continue;
f[fst]++;
f[lst+1]--;
}
int ans = 0;
int sum = 0;
for (auto& [x, y] : f) {
sum += y;
ans = max(ans, sum);
}
cout << ans << "\n";
}
/*#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
const int N = 1e6+6;
const ld EPS = 1e-10;
ld n, R, a[N], b[N], c[N], d[N];
map<int, int> f;
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> R;
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i] >> d[i];
ld x = c[i]-a[i];
ld y = d[i]-b[i];
ld l = 0;
ld r = 1e9;
while (r-l) {
ld mid = (l+r)/2;
bool in1 = (abs(a[i] + x*mid) + abs(b[i] + y*mid)) <= R;
bool in2 = (abs(a[i] + x*(mid+1)) + abs(b[i] + y*(mid+1))) <= R;
if (in1 && in2) r = mid;
else if (in1 && !in2) r = mid;
else if (!in1 && in2) r = mid+1;
else {
if (abs(a[i] + x*mid) + abs(b[i] + y*mid) <=
abs(a[i] + x*(mid+1)) + abs(b[i] + y*(mid+1))) {
r = mid;
}
else {
l = mid+1;
}
}
}
ld fst = l;
l = 0;
r = 1e9;
while (l < r) {
ld mid = (l+r)/2;
bool in1 = (abs(a[i] + x*mid) + abs(b[i] + y*mid)) <= R;
bool in2 = (abs(a[i] + x*(mid+1)) + abs(b[i] + y*(mid+1))) <= R;
if (in1 && in2) l = mid+1;
else if (in1 && !in2) l = mid;
else if (!in1 && in2) l = mid+1;
else {
if (abs(a[i] + x*mid) + abs(b[i] + y*mid) <
abs(a[i] + x*(mid+1)) + abs(b[i] + y*(mid+1))) {
r = mid;
}
else {
l = mid+1;
}
}
}
ld lst = l;
bool in1 = (abs(a[i] + x*fst) + abs(b[i] + y*fst)) <= R;
if (!in1) continue;
f[ceil(fst)]++;
f[floor(lst)+1]--;
}
int ans = 0;
int sum = 0;
for (auto& [x, y] : f) {
sum += y;
ans = max(ans, sum);
}
cout << ans << "\n";
}
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |