답안 #626589

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
626589 2022-08-11T14:48:41 Z mkisic Wish (LMIO19_noras) C++14
38 / 100
1000 ms 5740 KB
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

#define X first
#define Y second

typedef long long ll;
typedef pair<long long, long long> pii;

const int MAXN = 2e5 + 5;
const ll INF = (1LL << 50) + 5;

int n;
ll R;
vector<pii> dogadaji;

double udaljenost(pii T) { return sqrt((double)T.X * T.X + (double)T.Y * T.Y); }

pii izracunaj_tocku(ll x, ll y, ll sx, ll sy, ll t) {
  ll x2 = min(INF, x + t * sx);
  ll y2 = min(INF, y + t * sy);
  // cerr << x2 << ' ' << y2 << '\n';
  return {x2, y2};
}

void dodaj_tocku() {
  ll x, y, sx, sy;
  cin >> x >> y >> sx >> sy;

  sx -= x;
  sy -= y;

  // cerr << '\n' << x << ' ' << y << " : " << sx << ' ' << sy << '\n';

  ll l = 0, r = (1 << 30), m1, m2;

  while (r - l >= 3) {
    m1 = l + (r - l) / 3;
    m2 = r - (r - l) / 3;

    double d1 = udaljenost(izracunaj_tocku(x, y, sx, sy, m1));
    double d2 = udaljenost(izracunaj_tocku(x, y, sx, sy, m2));

    // cerr << l << ' ' << r << " : " << m1 << ' ' << m2 << " : " << d1 << ' '
    // << d2 << '\n';

    if (d1 < d2)
      r = m2;
    else
      l = m1;
  }

  for (int i = l + 1; i <= r; i++) {
    if (udaljenost(izracunaj_tocku(x, y, sx, sy, l)) >
        udaljenost(izracunaj_tocku(x, y, sx, sy, i)))
      l = i;
  }

  pii sredina = izracunaj_tocku(x, y, sx, sy, l);
  ll xx = sredina.X;
  ll yy = sredina.Y;

  // cerr << "sredina " << l << " : " << xx << ' ' << yy;
  // cerr << " : " << udaljenost({xx, yy}) << ' ' << r << '\n';

  if (udaljenost({xx, yy}) > R)
    return;

  ll lo = 0, hi = l, mid;

  while (lo < hi) {
    mid = (lo + hi) / 2;

    double d = udaljenost(izracunaj_tocku(x, y, sx, sy, mid));

    // cerr << lo << ' ' << hi << " : " << mid << ' ' << d << ' ' << R << '\n';

    if (d <= R)
      hi = mid;
    else
      lo = mid + 1;
  }

  ll t1 = lo;

  lo = l, hi = (1 << 30);

  while (lo < hi) {
    mid = (lo + hi) / 2 + 1;

    double d = udaljenost(izracunaj_tocku(x, y, sx, sy, mid));

    if (d <= R)
      lo = mid;
    else
      hi = mid - 1;
  }

  ll t2 = lo;

  // cerr << t1 << ' ' << t2 << '\n';

  dogadaji.push_back({t1 * 2, +1});
  dogadaji.push_back({t2 * 2 + 1, -1});
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> n >> R;

  for (int i = 0; i < n; i++) {
    dodaj_tocku();
  }

  int maks = 0;
  int trenutno = 0;

  sort(dogadaji.begin(), dogadaji.end());

  // cerr << '\n';

  for (auto nx : dogadaji) {
    trenutno += nx.Y;
    maks = max(maks, trenutno);
    cerr << nx.X << ' ' << nx.Y << '\n';
  }

  cout << maks << '\n';

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 6 ms 340 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Correct 6 ms 340 KB Output is correct
7 Correct 7 ms 332 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 12 ms 424 KB Output is correct
15 Correct 14 ms 332 KB Output is correct
16 Correct 12 ms 404 KB Output is correct
17 Correct 14 ms 424 KB Output is correct
18 Correct 14 ms 328 KB Output is correct
19 Correct 9 ms 408 KB Output is correct
20 Correct 10 ms 340 KB Output is correct
21 Correct 9 ms 340 KB Output is correct
22 Correct 8 ms 404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 6 ms 340 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Correct 6 ms 340 KB Output is correct
7 Correct 7 ms 332 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 12 ms 424 KB Output is correct
15 Correct 14 ms 332 KB Output is correct
16 Correct 12 ms 404 KB Output is correct
17 Correct 14 ms 424 KB Output is correct
18 Correct 14 ms 328 KB Output is correct
19 Correct 9 ms 408 KB Output is correct
20 Correct 10 ms 340 KB Output is correct
21 Correct 9 ms 340 KB Output is correct
22 Correct 8 ms 404 KB Output is correct
23 Execution timed out 1087 ms 5740 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 6 ms 340 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Correct 6 ms 340 KB Output is correct
7 Correct 7 ms 332 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 12 ms 424 KB Output is correct
15 Correct 14 ms 332 KB Output is correct
16 Correct 12 ms 404 KB Output is correct
17 Correct 14 ms 424 KB Output is correct
18 Correct 14 ms 328 KB Output is correct
19 Correct 9 ms 408 KB Output is correct
20 Correct 10 ms 340 KB Output is correct
21 Correct 9 ms 340 KB Output is correct
22 Correct 8 ms 404 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 13 ms 340 KB Output is correct
25 Correct 12 ms 340 KB Output is correct
26 Correct 9 ms 328 KB Output is correct
27 Correct 10 ms 340 KB Output is correct
28 Correct 12 ms 412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 6 ms 340 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Correct 6 ms 340 KB Output is correct
7 Correct 7 ms 332 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 12 ms 424 KB Output is correct
15 Correct 14 ms 332 KB Output is correct
16 Correct 12 ms 404 KB Output is correct
17 Correct 14 ms 424 KB Output is correct
18 Correct 14 ms 328 KB Output is correct
19 Correct 9 ms 408 KB Output is correct
20 Correct 10 ms 340 KB Output is correct
21 Correct 9 ms 340 KB Output is correct
22 Correct 8 ms 404 KB Output is correct
23 Execution timed out 1087 ms 5740 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 6 ms 340 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 6 ms 340 KB Output is correct
6 Correct 6 ms 340 KB Output is correct
7 Correct 7 ms 332 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 12 ms 424 KB Output is correct
15 Correct 14 ms 332 KB Output is correct
16 Correct 12 ms 404 KB Output is correct
17 Correct 14 ms 424 KB Output is correct
18 Correct 14 ms 328 KB Output is correct
19 Correct 9 ms 408 KB Output is correct
20 Correct 10 ms 340 KB Output is correct
21 Correct 9 ms 340 KB Output is correct
22 Correct 8 ms 404 KB Output is correct
23 Execution timed out 1087 ms 5740 KB Time limit exceeded
24 Halted 0 ms 0 KB -