Submission #894978

# Submission time Handle Problem Language Result Execution time Memory
894978 2023-12-29T10:14:45 Z vjudge1 Wish (LMIO19_noras) C++17
0 / 100
7 ms 14940 KB
#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], f[N];

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 = INT_MAX;
    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 (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 = INT_MAX;
    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 (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;

    if ((abs(a[i] + x*fst) + abs(b[i] + y*fst)) > r) continue;
    f[fst]++;
    f[lst+1]--;
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i) f[i] += f[i-1];
    ans = max(ans, f[i]);
  }
  cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14940 KB Output is correct
2 Correct 6 ms 14824 KB Output is correct
3 Incorrect 7 ms 14940 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14940 KB Output is correct
2 Correct 6 ms 14824 KB Output is correct
3 Incorrect 7 ms 14940 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14940 KB Output is correct
2 Correct 6 ms 14824 KB Output is correct
3 Incorrect 7 ms 14940 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14940 KB Output is correct
2 Correct 6 ms 14824 KB Output is correct
3 Incorrect 7 ms 14940 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14940 KB Output is correct
2 Correct 6 ms 14824 KB Output is correct
3 Incorrect 7 ms 14940 KB Output isn't correct
4 Halted 0 ms 0 KB -