Submission #626592

# Submission time Handle Problem Language Result Execution time Memory
626592 2022-08-11T14:50:25 Z mkisic Wish (LMIO19_noras) C++14
93 / 100
475 ms 11960 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;
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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 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 1 ms 212 KB Output is correct
10 Correct 1 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 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 3 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 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 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 1 ms 212 KB Output is correct
10 Correct 1 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 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 3 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 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 204 ms 4472 KB Output is correct
24 Correct 201 ms 5788 KB Output is correct
25 Correct 191 ms 5924 KB Output is correct
26 Correct 199 ms 5760 KB Output is correct
27 Correct 169 ms 3868 KB Output is correct
28 Correct 189 ms 5952 KB Output is correct
29 Correct 204 ms 6080 KB Output is correct
30 Correct 191 ms 5928 KB Output is correct
31 Correct 189 ms 5892 KB Output is correct
32 Correct 211 ms 5852 KB Output is correct
33 Correct 201 ms 5860 KB Output is correct
34 Correct 213 ms 5976 KB Output is correct
35 Correct 210 ms 5952 KB Output is correct
36 Correct 209 ms 5920 KB Output is correct
37 Correct 182 ms 4032 KB Output is correct
38 Correct 171 ms 4276 KB Output is correct
39 Correct 172 ms 4056 KB Output is correct
40 Correct 171 ms 3880 KB Output is correct
41 Correct 166 ms 3996 KB Output is correct
42 Correct 174 ms 4120 KB Output is correct
43 Correct 437 ms 11592 KB Output is correct
44 Correct 432 ms 11648 KB Output is correct
45 Correct 475 ms 11580 KB Output is correct
46 Correct 425 ms 11564 KB Output is correct
47 Correct 452 ms 11672 KB Output is correct
48 Correct 416 ms 11208 KB Output is correct
49 Correct 428 ms 11352 KB Output is correct
50 Correct 435 ms 11144 KB Output is correct
51 Correct 413 ms 11156 KB Output is correct
52 Correct 426 ms 11172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 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 1 ms 212 KB Output is correct
10 Correct 1 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 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 3 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 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 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 1 ms 212 KB Output is correct
10 Correct 1 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 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 3 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 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 204 ms 4472 KB Output is correct
24 Correct 201 ms 5788 KB Output is correct
25 Correct 191 ms 5924 KB Output is correct
26 Correct 199 ms 5760 KB Output is correct
27 Correct 169 ms 3868 KB Output is correct
28 Correct 189 ms 5952 KB Output is correct
29 Correct 204 ms 6080 KB Output is correct
30 Correct 191 ms 5928 KB Output is correct
31 Correct 189 ms 5892 KB Output is correct
32 Correct 211 ms 5852 KB Output is correct
33 Correct 201 ms 5860 KB Output is correct
34 Correct 213 ms 5976 KB Output is correct
35 Correct 210 ms 5952 KB Output is correct
36 Correct 209 ms 5920 KB Output is correct
37 Correct 182 ms 4032 KB Output is correct
38 Correct 171 ms 4276 KB Output is correct
39 Correct 172 ms 4056 KB Output is correct
40 Correct 171 ms 3880 KB Output is correct
41 Correct 166 ms 3996 KB Output is correct
42 Correct 174 ms 4120 KB Output is correct
43 Correct 437 ms 11592 KB Output is correct
44 Correct 432 ms 11648 KB Output is correct
45 Correct 475 ms 11580 KB Output is correct
46 Correct 425 ms 11564 KB Output is correct
47 Correct 452 ms 11672 KB Output is correct
48 Correct 416 ms 11208 KB Output is correct
49 Correct 428 ms 11352 KB Output is correct
50 Correct 435 ms 11144 KB Output is correct
51 Correct 413 ms 11156 KB Output is correct
52 Correct 426 ms 11172 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 2 ms 340 KB Output is correct
55 Correct 3 ms 340 KB Output is correct
56 Correct 2 ms 340 KB Output is correct
57 Correct 2 ms 340 KB Output is correct
58 Correct 2 ms 340 KB Output is correct
59 Correct 187 ms 5768 KB Output is correct
60 Correct 168 ms 4100 KB Output is correct
61 Correct 171 ms 4032 KB Output is correct
62 Correct 168 ms 4172 KB Output is correct
63 Correct 179 ms 4156 KB Output is correct
64 Correct 188 ms 4216 KB Output is correct
65 Correct 168 ms 4032 KB Output is correct
66 Correct 170 ms 4048 KB Output is correct
67 Correct 188 ms 4068 KB Output is correct
68 Correct 211 ms 6212 KB Output is correct
69 Correct 216 ms 6072 KB Output is correct
70 Correct 213 ms 6080 KB Output is correct
71 Correct 205 ms 6036 KB Output is correct
72 Correct 213 ms 6044 KB Output is correct
73 Correct 176 ms 3816 KB Output is correct
74 Correct 177 ms 6140 KB Output is correct
75 Correct 179 ms 6016 KB Output is correct
76 Correct 178 ms 3980 KB Output is correct
77 Correct 408 ms 11888 KB Output is correct
78 Correct 434 ms 11868 KB Output is correct
79 Correct 442 ms 11960 KB Output is correct
80 Correct 431 ms 11948 KB Output is correct
81 Correct 417 ms 11952 KB Output is correct
82 Correct 418 ms 11456 KB Output is correct
83 Correct 426 ms 11404 KB Output is correct
84 Correct 430 ms 11508 KB Output is correct
85 Correct 445 ms 11440 KB Output is correct
86 Correct 430 ms 11392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 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 1 ms 212 KB Output is correct
10 Correct 1 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 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 3 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 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 204 ms 4472 KB Output is correct
24 Correct 201 ms 5788 KB Output is correct
25 Correct 191 ms 5924 KB Output is correct
26 Correct 199 ms 5760 KB Output is correct
27 Correct 169 ms 3868 KB Output is correct
28 Correct 189 ms 5952 KB Output is correct
29 Correct 204 ms 6080 KB Output is correct
30 Correct 191 ms 5928 KB Output is correct
31 Correct 189 ms 5892 KB Output is correct
32 Correct 211 ms 5852 KB Output is correct
33 Correct 201 ms 5860 KB Output is correct
34 Correct 213 ms 5976 KB Output is correct
35 Correct 210 ms 5952 KB Output is correct
36 Correct 209 ms 5920 KB Output is correct
37 Correct 182 ms 4032 KB Output is correct
38 Correct 171 ms 4276 KB Output is correct
39 Correct 172 ms 4056 KB Output is correct
40 Correct 171 ms 3880 KB Output is correct
41 Correct 166 ms 3996 KB Output is correct
42 Correct 174 ms 4120 KB Output is correct
43 Correct 437 ms 11592 KB Output is correct
44 Correct 432 ms 11648 KB Output is correct
45 Correct 475 ms 11580 KB Output is correct
46 Correct 425 ms 11564 KB Output is correct
47 Correct 452 ms 11672 KB Output is correct
48 Correct 416 ms 11208 KB Output is correct
49 Correct 428 ms 11352 KB Output is correct
50 Correct 435 ms 11144 KB Output is correct
51 Correct 413 ms 11156 KB Output is correct
52 Correct 426 ms 11172 KB Output is correct
53 Correct 187 ms 5768 KB Output is correct
54 Correct 168 ms 4100 KB Output is correct
55 Correct 171 ms 4032 KB Output is correct
56 Correct 168 ms 4172 KB Output is correct
57 Correct 179 ms 4156 KB Output is correct
58 Correct 188 ms 4216 KB Output is correct
59 Correct 168 ms 4032 KB Output is correct
60 Correct 170 ms 4048 KB Output is correct
61 Correct 188 ms 4068 KB Output is correct
62 Correct 211 ms 6212 KB Output is correct
63 Correct 216 ms 6072 KB Output is correct
64 Correct 213 ms 6080 KB Output is correct
65 Correct 205 ms 6036 KB Output is correct
66 Correct 213 ms 6044 KB Output is correct
67 Correct 176 ms 3816 KB Output is correct
68 Correct 177 ms 6140 KB Output is correct
69 Correct 179 ms 6016 KB Output is correct
70 Correct 178 ms 3980 KB Output is correct
71 Correct 408 ms 11888 KB Output is correct
72 Correct 434 ms 11868 KB Output is correct
73 Correct 442 ms 11960 KB Output is correct
74 Correct 431 ms 11948 KB Output is correct
75 Correct 417 ms 11952 KB Output is correct
76 Correct 418 ms 11456 KB Output is correct
77 Correct 426 ms 11404 KB Output is correct
78 Correct 430 ms 11508 KB Output is correct
79 Correct 445 ms 11440 KB Output is correct
80 Correct 430 ms 11392 KB Output is correct
81 Correct 0 ms 212 KB Output is correct
82 Correct 2 ms 340 KB Output is correct
83 Correct 3 ms 340 KB Output is correct
84 Correct 2 ms 340 KB Output is correct
85 Correct 2 ms 340 KB Output is correct
86 Correct 2 ms 340 KB Output is correct
87 Correct 206 ms 5564 KB Output is correct
88 Correct 192 ms 5548 KB Output is correct
89 Correct 194 ms 5336 KB Output is correct
90 Correct 183 ms 5424 KB Output is correct
91 Correct 189 ms 5448 KB Output is correct
92 Correct 192 ms 5468 KB Output is correct
93 Correct 191 ms 5392 KB Output is correct
94 Correct 188 ms 5496 KB Output is correct
95 Correct 201 ms 5468 KB Output is correct
96 Correct 187 ms 5460 KB Output is correct
97 Incorrect 166 ms 4224 KB Output isn't correct
98 Halted 0 ms 0 KB -