답안 #213065

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
213065 2020-03-24T23:04:36 Z qkxwsm Wish (LMIO19_noras) C++14
93 / 100
146 ms 5880 KB
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef pair<pll, pll> ppp;

const int MAXN = 200013;

int N, R;
int ans;
map<ll, int> pref;

ll fdiv(ll a, ll b)
{
    return a / b - (a % b < 0);
}
ll cdiv(ll a, ll b)
{
    return a / b + (a % b > 0);
}

int32_t main()
{
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(4);
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N >> R;
    FOR(i, 0, N)
    {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        c -= a; d -= b;
        ll r = c * c + d * d;
        ll s = 2 * b * d + 2 * a * c;
        ll t = a * a + b * b - R * R;
        // cerr << r << ' ' << s << ' ' << t << endl;
        if (s * s - 4 * r * t < 0) continue;
        ll sq = sqrt(s * s - 4 * r * t) + 2;
        while(sq * sq > s * s - 4 * r * t) sq--;
        // cerr << -s-sq << ' ' << -s + sq << ' ' << 2 * r << endl;
        ll lo = cdiv(-s - sq, 2 * r), hi = fdiv(-s + sq, 2 * r);
        // cerr << lo << '@' << hi << endl;
        ckmax(lo, 0);
        if (lo > hi) continue;
        // cerr << lo << ',' << hi << endl;
        pref[lo]++; pref[hi + 1]--;
    }
    if (pref.empty())
    {
        cout << "0\n";
        return 0;
    }
    for (auto it = next(pref.begin()); it != pref.end(); it++)
    {
        it -> se += (prev(it)) -> se;
    }
    for (auto p : pref)
    {
        ckmax(ans, p.se);
    }
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 44 ms 1912 KB Output is correct
24 Correct 41 ms 1912 KB Output is correct
25 Correct 42 ms 1912 KB Output is correct
26 Correct 44 ms 1920 KB Output is correct
27 Correct 44 ms 2176 KB Output is correct
28 Correct 43 ms 2048 KB Output is correct
29 Correct 42 ms 2168 KB Output is correct
30 Correct 41 ms 2168 KB Output is correct
31 Correct 40 ms 2168 KB Output is correct
32 Correct 59 ms 2168 KB Output is correct
33 Correct 56 ms 2168 KB Output is correct
34 Correct 59 ms 2168 KB Output is correct
35 Correct 56 ms 2172 KB Output is correct
36 Correct 56 ms 2168 KB Output is correct
37 Correct 42 ms 1912 KB Output is correct
38 Correct 41 ms 1912 KB Output is correct
39 Correct 41 ms 1912 KB Output is correct
40 Correct 42 ms 1912 KB Output is correct
41 Correct 41 ms 1912 KB Output is correct
42 Correct 43 ms 1912 KB Output is correct
43 Correct 138 ms 5880 KB Output is correct
44 Correct 141 ms 5880 KB Output is correct
45 Correct 146 ms 5880 KB Output is correct
46 Correct 142 ms 5880 KB Output is correct
47 Correct 139 ms 5880 KB Output is correct
48 Correct 107 ms 3960 KB Output is correct
49 Correct 109 ms 3832 KB Output is correct
50 Correct 110 ms 3832 KB Output is correct
51 Correct 110 ms 3832 KB Output is correct
52 Correct 105 ms 3832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 8 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 44 ms 1912 KB Output is correct
24 Correct 41 ms 1912 KB Output is correct
25 Correct 42 ms 1912 KB Output is correct
26 Correct 44 ms 1920 KB Output is correct
27 Correct 44 ms 2176 KB Output is correct
28 Correct 43 ms 2048 KB Output is correct
29 Correct 42 ms 2168 KB Output is correct
30 Correct 41 ms 2168 KB Output is correct
31 Correct 40 ms 2168 KB Output is correct
32 Correct 59 ms 2168 KB Output is correct
33 Correct 56 ms 2168 KB Output is correct
34 Correct 59 ms 2168 KB Output is correct
35 Correct 56 ms 2172 KB Output is correct
36 Correct 56 ms 2168 KB Output is correct
37 Correct 42 ms 1912 KB Output is correct
38 Correct 41 ms 1912 KB Output is correct
39 Correct 41 ms 1912 KB Output is correct
40 Correct 42 ms 1912 KB Output is correct
41 Correct 41 ms 1912 KB Output is correct
42 Correct 43 ms 1912 KB Output is correct
43 Correct 138 ms 5880 KB Output is correct
44 Correct 141 ms 5880 KB Output is correct
45 Correct 146 ms 5880 KB Output is correct
46 Correct 142 ms 5880 KB Output is correct
47 Correct 139 ms 5880 KB Output is correct
48 Correct 107 ms 3960 KB Output is correct
49 Correct 109 ms 3832 KB Output is correct
50 Correct 110 ms 3832 KB Output is correct
51 Correct 110 ms 3832 KB Output is correct
52 Correct 105 ms 3832 KB Output is correct
53 Correct 43 ms 1912 KB Output is correct
54 Correct 48 ms 2424 KB Output is correct
55 Correct 48 ms 2424 KB Output is correct
56 Correct 45 ms 2424 KB Output is correct
57 Correct 59 ms 2936 KB Output is correct
58 Correct 56 ms 2936 KB Output is correct
59 Correct 55 ms 2936 KB Output is correct
60 Correct 57 ms 2936 KB Output is correct
61 Correct 57 ms 2936 KB Output is correct
62 Correct 59 ms 2300 KB Output is correct
63 Correct 59 ms 2296 KB Output is correct
64 Correct 60 ms 2296 KB Output is correct
65 Correct 60 ms 2296 KB Output is correct
66 Correct 58 ms 2296 KB Output is correct
67 Correct 43 ms 1920 KB Output is correct
68 Correct 43 ms 1912 KB Output is correct
69 Correct 44 ms 1920 KB Output is correct
70 Correct 45 ms 2040 KB Output is correct
71 Correct 138 ms 5880 KB Output is correct
72 Correct 131 ms 5880 KB Output is correct
73 Correct 134 ms 5880 KB Output is correct
74 Correct 133 ms 5880 KB Output is correct
75 Correct 141 ms 5880 KB Output is correct
76 Correct 115 ms 4216 KB Output is correct
77 Correct 118 ms 4216 KB Output is correct
78 Correct 112 ms 4216 KB Output is correct
79 Correct 112 ms 4216 KB Output is correct
80 Correct 120 ms 4216 KB Output is correct
81 Correct 5 ms 384 KB Output is correct
82 Correct 5 ms 384 KB Output is correct
83 Correct 5 ms 384 KB Output is correct
84 Correct 5 ms 384 KB Output is correct
85 Correct 5 ms 384 KB Output is correct
86 Correct 8 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 44 ms 1912 KB Output is correct
24 Correct 41 ms 1912 KB Output is correct
25 Correct 42 ms 1912 KB Output is correct
26 Correct 44 ms 1920 KB Output is correct
27 Correct 44 ms 2176 KB Output is correct
28 Correct 43 ms 2048 KB Output is correct
29 Correct 42 ms 2168 KB Output is correct
30 Correct 41 ms 2168 KB Output is correct
31 Correct 40 ms 2168 KB Output is correct
32 Correct 59 ms 2168 KB Output is correct
33 Correct 56 ms 2168 KB Output is correct
34 Correct 59 ms 2168 KB Output is correct
35 Correct 56 ms 2172 KB Output is correct
36 Correct 56 ms 2168 KB Output is correct
37 Correct 42 ms 1912 KB Output is correct
38 Correct 41 ms 1912 KB Output is correct
39 Correct 41 ms 1912 KB Output is correct
40 Correct 42 ms 1912 KB Output is correct
41 Correct 41 ms 1912 KB Output is correct
42 Correct 43 ms 1912 KB Output is correct
43 Correct 138 ms 5880 KB Output is correct
44 Correct 141 ms 5880 KB Output is correct
45 Correct 146 ms 5880 KB Output is correct
46 Correct 142 ms 5880 KB Output is correct
47 Correct 139 ms 5880 KB Output is correct
48 Correct 107 ms 3960 KB Output is correct
49 Correct 109 ms 3832 KB Output is correct
50 Correct 110 ms 3832 KB Output is correct
51 Correct 110 ms 3832 KB Output is correct
52 Correct 105 ms 3832 KB Output is correct
53 Correct 43 ms 1912 KB Output is correct
54 Correct 48 ms 2424 KB Output is correct
55 Correct 48 ms 2424 KB Output is correct
56 Correct 45 ms 2424 KB Output is correct
57 Correct 59 ms 2936 KB Output is correct
58 Correct 56 ms 2936 KB Output is correct
59 Correct 55 ms 2936 KB Output is correct
60 Correct 57 ms 2936 KB Output is correct
61 Correct 57 ms 2936 KB Output is correct
62 Correct 59 ms 2300 KB Output is correct
63 Correct 59 ms 2296 KB Output is correct
64 Correct 60 ms 2296 KB Output is correct
65 Correct 60 ms 2296 KB Output is correct
66 Correct 58 ms 2296 KB Output is correct
67 Correct 43 ms 1920 KB Output is correct
68 Correct 43 ms 1912 KB Output is correct
69 Correct 44 ms 1920 KB Output is correct
70 Correct 45 ms 2040 KB Output is correct
71 Correct 138 ms 5880 KB Output is correct
72 Correct 131 ms 5880 KB Output is correct
73 Correct 134 ms 5880 KB Output is correct
74 Correct 133 ms 5880 KB Output is correct
75 Correct 141 ms 5880 KB Output is correct
76 Correct 115 ms 4216 KB Output is correct
77 Correct 118 ms 4216 KB Output is correct
78 Correct 112 ms 4216 KB Output is correct
79 Correct 112 ms 4216 KB Output is correct
80 Correct 120 ms 4216 KB Output is correct
81 Incorrect 64 ms 4600 KB Output isn't correct
82 Halted 0 ms 0 KB -