답안 #626594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
626594 2022-08-11T14:51:27 Z mkisic Wish (LMIO19_noras) C++14
100 / 100
508 ms 8756 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 << 60) + 5;
const ll INF_binary = (1 << 30);

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 = INF_binary, 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 = INF_binary;

  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);
  }

  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 2 ms 316 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 3 ms 324 KB Output is correct
22 Correct 2 ms 340 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 2 ms 316 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 3 ms 324 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 196 ms 4544 KB Output is correct
24 Correct 189 ms 4508 KB Output is correct
25 Correct 193 ms 4608 KB Output is correct
26 Correct 196 ms 4456 KB Output is correct
27 Correct 166 ms 2472 KB Output is correct
28 Correct 184 ms 4524 KB Output is correct
29 Correct 192 ms 4496 KB Output is correct
30 Correct 185 ms 4508 KB Output is correct
31 Correct 187 ms 4464 KB Output is correct
32 Correct 213 ms 4452 KB Output is correct
33 Correct 203 ms 4460 KB Output is correct
34 Correct 205 ms 4536 KB Output is correct
35 Correct 212 ms 4528 KB Output is correct
36 Correct 223 ms 4480 KB Output is correct
37 Correct 171 ms 2504 KB Output is correct
38 Correct 174 ms 2432 KB Output is correct
39 Correct 165 ms 2480 KB Output is correct
40 Correct 171 ms 2476 KB Output is correct
41 Correct 164 ms 2476 KB Output is correct
42 Correct 173 ms 2504 KB Output is correct
43 Correct 430 ms 8632 KB Output is correct
44 Correct 428 ms 8680 KB Output is correct
45 Correct 439 ms 8648 KB Output is correct
46 Correct 446 ms 8552 KB Output is correct
47 Correct 481 ms 8624 KB Output is correct
48 Correct 508 ms 8632 KB Output is correct
49 Correct 443 ms 8564 KB Output is correct
50 Correct 442 ms 8624 KB Output is correct
51 Correct 413 ms 8736 KB Output is correct
52 Correct 443 ms 8608 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 2 ms 316 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 3 ms 324 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 340 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 2 ms 316 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 3 ms 324 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 196 ms 4544 KB Output is correct
24 Correct 189 ms 4508 KB Output is correct
25 Correct 193 ms 4608 KB Output is correct
26 Correct 196 ms 4456 KB Output is correct
27 Correct 166 ms 2472 KB Output is correct
28 Correct 184 ms 4524 KB Output is correct
29 Correct 192 ms 4496 KB Output is correct
30 Correct 185 ms 4508 KB Output is correct
31 Correct 187 ms 4464 KB Output is correct
32 Correct 213 ms 4452 KB Output is correct
33 Correct 203 ms 4460 KB Output is correct
34 Correct 205 ms 4536 KB Output is correct
35 Correct 212 ms 4528 KB Output is correct
36 Correct 223 ms 4480 KB Output is correct
37 Correct 171 ms 2504 KB Output is correct
38 Correct 174 ms 2432 KB Output is correct
39 Correct 165 ms 2480 KB Output is correct
40 Correct 171 ms 2476 KB Output is correct
41 Correct 164 ms 2476 KB Output is correct
42 Correct 173 ms 2504 KB Output is correct
43 Correct 430 ms 8632 KB Output is correct
44 Correct 428 ms 8680 KB Output is correct
45 Correct 439 ms 8648 KB Output is correct
46 Correct 446 ms 8552 KB Output is correct
47 Correct 481 ms 8624 KB Output is correct
48 Correct 508 ms 8632 KB Output is correct
49 Correct 443 ms 8564 KB Output is correct
50 Correct 442 ms 8624 KB Output is correct
51 Correct 413 ms 8736 KB Output is correct
52 Correct 443 ms 8608 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 3 ms 340 KB Output is correct
55 Correct 2 ms 340 KB Output is correct
56 Correct 2 ms 340 KB Output is correct
57 Correct 3 ms 340 KB Output is correct
58 Correct 3 ms 340 KB Output is correct
59 Correct 207 ms 4544 KB Output is correct
60 Correct 171 ms 2400 KB Output is correct
61 Correct 184 ms 2492 KB Output is correct
62 Correct 185 ms 2448 KB Output is correct
63 Correct 197 ms 2428 KB Output is correct
64 Correct 182 ms 2500 KB Output is correct
65 Correct 182 ms 2500 KB Output is correct
66 Correct 195 ms 2452 KB Output is correct
67 Correct 184 ms 2432 KB Output is correct
68 Correct 232 ms 4464 KB Output is correct
69 Correct 244 ms 4464 KB Output is correct
70 Correct 234 ms 4536 KB Output is correct
71 Correct 221 ms 4504 KB Output is correct
72 Correct 227 ms 4496 KB Output is correct
73 Correct 190 ms 2508 KB Output is correct
74 Correct 190 ms 4476 KB Output is correct
75 Correct 201 ms 4504 KB Output is correct
76 Correct 205 ms 2440 KB Output is correct
77 Correct 452 ms 8656 KB Output is correct
78 Correct 487 ms 8656 KB Output is correct
79 Correct 437 ms 8592 KB Output is correct
80 Correct 497 ms 8672 KB Output is correct
81 Correct 445 ms 8716 KB Output is correct
82 Correct 434 ms 8576 KB Output is correct
83 Correct 452 ms 8660 KB Output is correct
84 Correct 434 ms 8756 KB Output is correct
85 Correct 434 ms 8664 KB Output is correct
86 Correct 428 ms 8652 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 2 ms 316 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 3 ms 324 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 196 ms 4544 KB Output is correct
24 Correct 189 ms 4508 KB Output is correct
25 Correct 193 ms 4608 KB Output is correct
26 Correct 196 ms 4456 KB Output is correct
27 Correct 166 ms 2472 KB Output is correct
28 Correct 184 ms 4524 KB Output is correct
29 Correct 192 ms 4496 KB Output is correct
30 Correct 185 ms 4508 KB Output is correct
31 Correct 187 ms 4464 KB Output is correct
32 Correct 213 ms 4452 KB Output is correct
33 Correct 203 ms 4460 KB Output is correct
34 Correct 205 ms 4536 KB Output is correct
35 Correct 212 ms 4528 KB Output is correct
36 Correct 223 ms 4480 KB Output is correct
37 Correct 171 ms 2504 KB Output is correct
38 Correct 174 ms 2432 KB Output is correct
39 Correct 165 ms 2480 KB Output is correct
40 Correct 171 ms 2476 KB Output is correct
41 Correct 164 ms 2476 KB Output is correct
42 Correct 173 ms 2504 KB Output is correct
43 Correct 430 ms 8632 KB Output is correct
44 Correct 428 ms 8680 KB Output is correct
45 Correct 439 ms 8648 KB Output is correct
46 Correct 446 ms 8552 KB Output is correct
47 Correct 481 ms 8624 KB Output is correct
48 Correct 508 ms 8632 KB Output is correct
49 Correct 443 ms 8564 KB Output is correct
50 Correct 442 ms 8624 KB Output is correct
51 Correct 413 ms 8736 KB Output is correct
52 Correct 443 ms 8608 KB Output is correct
53 Correct 207 ms 4544 KB Output is correct
54 Correct 171 ms 2400 KB Output is correct
55 Correct 184 ms 2492 KB Output is correct
56 Correct 185 ms 2448 KB Output is correct
57 Correct 197 ms 2428 KB Output is correct
58 Correct 182 ms 2500 KB Output is correct
59 Correct 182 ms 2500 KB Output is correct
60 Correct 195 ms 2452 KB Output is correct
61 Correct 184 ms 2432 KB Output is correct
62 Correct 232 ms 4464 KB Output is correct
63 Correct 244 ms 4464 KB Output is correct
64 Correct 234 ms 4536 KB Output is correct
65 Correct 221 ms 4504 KB Output is correct
66 Correct 227 ms 4496 KB Output is correct
67 Correct 190 ms 2508 KB Output is correct
68 Correct 190 ms 4476 KB Output is correct
69 Correct 201 ms 4504 KB Output is correct
70 Correct 205 ms 2440 KB Output is correct
71 Correct 452 ms 8656 KB Output is correct
72 Correct 487 ms 8656 KB Output is correct
73 Correct 437 ms 8592 KB Output is correct
74 Correct 497 ms 8672 KB Output is correct
75 Correct 445 ms 8716 KB Output is correct
76 Correct 434 ms 8576 KB Output is correct
77 Correct 452 ms 8660 KB Output is correct
78 Correct 434 ms 8756 KB Output is correct
79 Correct 434 ms 8664 KB Output is correct
80 Correct 428 ms 8652 KB Output is correct
81 Correct 0 ms 212 KB Output is correct
82 Correct 3 ms 340 KB Output is correct
83 Correct 2 ms 340 KB Output is correct
84 Correct 2 ms 340 KB Output is correct
85 Correct 3 ms 340 KB Output is correct
86 Correct 3 ms 340 KB Output is correct
87 Correct 212 ms 2416 KB Output is correct
88 Correct 184 ms 2456 KB Output is correct
89 Correct 180 ms 2496 KB Output is correct
90 Correct 205 ms 2400 KB Output is correct
91 Correct 188 ms 2388 KB Output is correct
92 Correct 182 ms 2428 KB Output is correct
93 Correct 189 ms 2424 KB Output is correct
94 Correct 193 ms 2444 KB Output is correct
95 Correct 181 ms 2484 KB Output is correct
96 Correct 184 ms 2476 KB Output is correct
97 Correct 199 ms 4532 KB Output is correct
98 Correct 193 ms 6332 KB Output is correct
99 Correct 196 ms 6264 KB Output is correct
100 Correct 209 ms 6240 KB Output is correct
101 Correct 194 ms 6336 KB Output is correct
102 Correct 189 ms 6320 KB Output is correct
103 Correct 196 ms 6324 KB Output is correct
104 Correct 194 ms 6232 KB Output is correct
105 Correct 203 ms 6324 KB Output is correct
106 Correct 190 ms 6224 KB Output is correct