# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
716178 |
2023-03-29T07:48:15 Z |
amunduzbaev |
Wish (LMIO19_noras) |
C++17 |
|
226 ms |
18176 KB |
#include "bits/stdc++.h"
using namespace std;
#define ar array
typedef long long ll;
#define int ll
const int N = 2e5 + 5;
const int MX = 1e9;
ll a[N], b[N], c[N], d[N];
int l_[N], r_[N];
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
ll n, R; cin >> n >> R;
for(int i=0;i<n;i++){
cin >> a[i] >> b[i] >> c[i] >> d[i];
c[i] -= a[i], d[i] -= b[i];
}
auto sq = [&](__int128 x) -> __int128{
return x * x;
};
for(int i=0;i<n;i++){
auto check = [&](__int128 t) -> __int128{
int x = a[i] + c[i] * t, y = b[i] + d[i] * t;
return sq(x) + sq(y);
};
int l = 0, r = MX;
//~ if(c[i]) r = abs(MX / c[i]);
//~ if(d[i]) r = min(r, abs(MX / d[i]));
int mx = r;
while(l + 2 < r){
int m = (l + r) >> 1;
if(check(m) <= check(m + 1)){
r = m + 1;
} else {
l = m;
}
}
l_[i] = r_[i] = -1;
int T = l;
if(check(T) > check(l + 1)) T = l + 1;
if(check(T) > check(r)) T = r;
if(check(T) > sq(R)) continue;
l = 0, r = T;
while(l < r){
int m = (l + r) >> 1;
if(check(m) <= sq(R)) r = m;
else l = m + 1;
}
l_[i] = l;
l = T, r = mx;
while(l < r){
int m = (l + r) >> 1;
if(check(m) > sq(R)) r = m;
else l = m + 1;
}
r_[i] = l;
}
vector<ar<int, 2>> tot;
for(int i=0;i<n;i++){
tot.push_back({l_[i], 1});
tot.push_back({r_[i], -1});
}
sort(tot.begin(), tot.end());
ll res = 0, cur = 0;
for(auto [a, b] : tot){
cur += b;
res = max(res, cur);
}
cout<<res<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
64 ms |
9184 KB |
Output is correct |
24 |
Correct |
76 ms |
9188 KB |
Output is correct |
25 |
Correct |
85 ms |
9176 KB |
Output is correct |
26 |
Correct |
74 ms |
9272 KB |
Output is correct |
27 |
Correct |
61 ms |
9256 KB |
Output is correct |
28 |
Correct |
66 ms |
9268 KB |
Output is correct |
29 |
Correct |
66 ms |
9236 KB |
Output is correct |
30 |
Correct |
75 ms |
9188 KB |
Output is correct |
31 |
Correct |
70 ms |
9264 KB |
Output is correct |
32 |
Correct |
84 ms |
9284 KB |
Output is correct |
33 |
Correct |
83 ms |
9168 KB |
Output is correct |
34 |
Correct |
90 ms |
9200 KB |
Output is correct |
35 |
Correct |
94 ms |
9272 KB |
Output is correct |
36 |
Correct |
84 ms |
9232 KB |
Output is correct |
37 |
Correct |
64 ms |
9176 KB |
Output is correct |
38 |
Correct |
71 ms |
9172 KB |
Output is correct |
39 |
Correct |
64 ms |
9280 KB |
Output is correct |
40 |
Correct |
83 ms |
9264 KB |
Output is correct |
41 |
Correct |
68 ms |
9252 KB |
Output is correct |
42 |
Correct |
70 ms |
9296 KB |
Output is correct |
43 |
Correct |
188 ms |
17980 KB |
Output is correct |
44 |
Correct |
204 ms |
18008 KB |
Output is correct |
45 |
Correct |
186 ms |
17972 KB |
Output is correct |
46 |
Correct |
187 ms |
17952 KB |
Output is correct |
47 |
Correct |
200 ms |
18064 KB |
Output is correct |
48 |
Correct |
170 ms |
18056 KB |
Output is correct |
49 |
Correct |
175 ms |
18076 KB |
Output is correct |
50 |
Correct |
176 ms |
17944 KB |
Output is correct |
51 |
Correct |
180 ms |
18072 KB |
Output is correct |
52 |
Correct |
166 ms |
17984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
2 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
64 ms |
9184 KB |
Output is correct |
24 |
Correct |
76 ms |
9188 KB |
Output is correct |
25 |
Correct |
85 ms |
9176 KB |
Output is correct |
26 |
Correct |
74 ms |
9272 KB |
Output is correct |
27 |
Correct |
61 ms |
9256 KB |
Output is correct |
28 |
Correct |
66 ms |
9268 KB |
Output is correct |
29 |
Correct |
66 ms |
9236 KB |
Output is correct |
30 |
Correct |
75 ms |
9188 KB |
Output is correct |
31 |
Correct |
70 ms |
9264 KB |
Output is correct |
32 |
Correct |
84 ms |
9284 KB |
Output is correct |
33 |
Correct |
83 ms |
9168 KB |
Output is correct |
34 |
Correct |
90 ms |
9200 KB |
Output is correct |
35 |
Correct |
94 ms |
9272 KB |
Output is correct |
36 |
Correct |
84 ms |
9232 KB |
Output is correct |
37 |
Correct |
64 ms |
9176 KB |
Output is correct |
38 |
Correct |
71 ms |
9172 KB |
Output is correct |
39 |
Correct |
64 ms |
9280 KB |
Output is correct |
40 |
Correct |
83 ms |
9264 KB |
Output is correct |
41 |
Correct |
68 ms |
9252 KB |
Output is correct |
42 |
Correct |
70 ms |
9296 KB |
Output is correct |
43 |
Correct |
188 ms |
17980 KB |
Output is correct |
44 |
Correct |
204 ms |
18008 KB |
Output is correct |
45 |
Correct |
186 ms |
17972 KB |
Output is correct |
46 |
Correct |
187 ms |
17952 KB |
Output is correct |
47 |
Correct |
200 ms |
18064 KB |
Output is correct |
48 |
Correct |
170 ms |
18056 KB |
Output is correct |
49 |
Correct |
175 ms |
18076 KB |
Output is correct |
50 |
Correct |
176 ms |
17944 KB |
Output is correct |
51 |
Correct |
180 ms |
18072 KB |
Output is correct |
52 |
Correct |
166 ms |
17984 KB |
Output is correct |
53 |
Correct |
0 ms |
340 KB |
Output is correct |
54 |
Correct |
1 ms |
468 KB |
Output is correct |
55 |
Correct |
2 ms |
468 KB |
Output is correct |
56 |
Correct |
1 ms |
468 KB |
Output is correct |
57 |
Correct |
2 ms |
468 KB |
Output is correct |
58 |
Correct |
1 ms |
468 KB |
Output is correct |
59 |
Correct |
74 ms |
9356 KB |
Output is correct |
60 |
Correct |
64 ms |
9156 KB |
Output is correct |
61 |
Correct |
65 ms |
9248 KB |
Output is correct |
62 |
Correct |
66 ms |
9184 KB |
Output is correct |
63 |
Correct |
75 ms |
9160 KB |
Output is correct |
64 |
Correct |
78 ms |
9160 KB |
Output is correct |
65 |
Correct |
80 ms |
9176 KB |
Output is correct |
66 |
Correct |
75 ms |
9264 KB |
Output is correct |
67 |
Correct |
75 ms |
9184 KB |
Output is correct |
68 |
Correct |
93 ms |
9284 KB |
Output is correct |
69 |
Correct |
114 ms |
9268 KB |
Output is correct |
70 |
Correct |
93 ms |
9292 KB |
Output is correct |
71 |
Correct |
92 ms |
9224 KB |
Output is correct |
72 |
Correct |
85 ms |
9264 KB |
Output is correct |
73 |
Correct |
70 ms |
9264 KB |
Output is correct |
74 |
Correct |
73 ms |
9284 KB |
Output is correct |
75 |
Correct |
72 ms |
9180 KB |
Output is correct |
76 |
Correct |
66 ms |
9176 KB |
Output is correct |
77 |
Correct |
193 ms |
18128 KB |
Output is correct |
78 |
Correct |
197 ms |
18176 KB |
Output is correct |
79 |
Correct |
185 ms |
17948 KB |
Output is correct |
80 |
Correct |
206 ms |
18056 KB |
Output is correct |
81 |
Correct |
226 ms |
17968 KB |
Output is correct |
82 |
Correct |
177 ms |
17980 KB |
Output is correct |
83 |
Correct |
185 ms |
18028 KB |
Output is correct |
84 |
Correct |
182 ms |
17984 KB |
Output is correct |
85 |
Correct |
175 ms |
17988 KB |
Output is correct |
86 |
Correct |
194 ms |
18044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
64 ms |
9184 KB |
Output is correct |
24 |
Correct |
76 ms |
9188 KB |
Output is correct |
25 |
Correct |
85 ms |
9176 KB |
Output is correct |
26 |
Correct |
74 ms |
9272 KB |
Output is correct |
27 |
Correct |
61 ms |
9256 KB |
Output is correct |
28 |
Correct |
66 ms |
9268 KB |
Output is correct |
29 |
Correct |
66 ms |
9236 KB |
Output is correct |
30 |
Correct |
75 ms |
9188 KB |
Output is correct |
31 |
Correct |
70 ms |
9264 KB |
Output is correct |
32 |
Correct |
84 ms |
9284 KB |
Output is correct |
33 |
Correct |
83 ms |
9168 KB |
Output is correct |
34 |
Correct |
90 ms |
9200 KB |
Output is correct |
35 |
Correct |
94 ms |
9272 KB |
Output is correct |
36 |
Correct |
84 ms |
9232 KB |
Output is correct |
37 |
Correct |
64 ms |
9176 KB |
Output is correct |
38 |
Correct |
71 ms |
9172 KB |
Output is correct |
39 |
Correct |
64 ms |
9280 KB |
Output is correct |
40 |
Correct |
83 ms |
9264 KB |
Output is correct |
41 |
Correct |
68 ms |
9252 KB |
Output is correct |
42 |
Correct |
70 ms |
9296 KB |
Output is correct |
43 |
Correct |
188 ms |
17980 KB |
Output is correct |
44 |
Correct |
204 ms |
18008 KB |
Output is correct |
45 |
Correct |
186 ms |
17972 KB |
Output is correct |
46 |
Correct |
187 ms |
17952 KB |
Output is correct |
47 |
Correct |
200 ms |
18064 KB |
Output is correct |
48 |
Correct |
170 ms |
18056 KB |
Output is correct |
49 |
Correct |
175 ms |
18076 KB |
Output is correct |
50 |
Correct |
176 ms |
17944 KB |
Output is correct |
51 |
Correct |
180 ms |
18072 KB |
Output is correct |
52 |
Correct |
166 ms |
17984 KB |
Output is correct |
53 |
Correct |
74 ms |
9356 KB |
Output is correct |
54 |
Correct |
64 ms |
9156 KB |
Output is correct |
55 |
Correct |
65 ms |
9248 KB |
Output is correct |
56 |
Correct |
66 ms |
9184 KB |
Output is correct |
57 |
Correct |
75 ms |
9160 KB |
Output is correct |
58 |
Correct |
78 ms |
9160 KB |
Output is correct |
59 |
Correct |
80 ms |
9176 KB |
Output is correct |
60 |
Correct |
75 ms |
9264 KB |
Output is correct |
61 |
Correct |
75 ms |
9184 KB |
Output is correct |
62 |
Correct |
93 ms |
9284 KB |
Output is correct |
63 |
Correct |
114 ms |
9268 KB |
Output is correct |
64 |
Correct |
93 ms |
9292 KB |
Output is correct |
65 |
Correct |
92 ms |
9224 KB |
Output is correct |
66 |
Correct |
85 ms |
9264 KB |
Output is correct |
67 |
Correct |
70 ms |
9264 KB |
Output is correct |
68 |
Correct |
73 ms |
9284 KB |
Output is correct |
69 |
Correct |
72 ms |
9180 KB |
Output is correct |
70 |
Correct |
66 ms |
9176 KB |
Output is correct |
71 |
Correct |
193 ms |
18128 KB |
Output is correct |
72 |
Correct |
197 ms |
18176 KB |
Output is correct |
73 |
Correct |
185 ms |
17948 KB |
Output is correct |
74 |
Correct |
206 ms |
18056 KB |
Output is correct |
75 |
Correct |
226 ms |
17968 KB |
Output is correct |
76 |
Correct |
177 ms |
17980 KB |
Output is correct |
77 |
Correct |
185 ms |
18028 KB |
Output is correct |
78 |
Correct |
182 ms |
17984 KB |
Output is correct |
79 |
Correct |
175 ms |
17988 KB |
Output is correct |
80 |
Correct |
194 ms |
18044 KB |
Output is correct |
81 |
Correct |
0 ms |
340 KB |
Output is correct |
82 |
Correct |
1 ms |
468 KB |
Output is correct |
83 |
Correct |
2 ms |
468 KB |
Output is correct |
84 |
Correct |
1 ms |
468 KB |
Output is correct |
85 |
Correct |
2 ms |
468 KB |
Output is correct |
86 |
Correct |
1 ms |
468 KB |
Output is correct |
87 |
Correct |
94 ms |
9236 KB |
Output is correct |
88 |
Correct |
85 ms |
9160 KB |
Output is correct |
89 |
Correct |
89 ms |
9156 KB |
Output is correct |
90 |
Correct |
86 ms |
9176 KB |
Output is correct |
91 |
Correct |
105 ms |
9216 KB |
Output is correct |
92 |
Correct |
98 ms |
9140 KB |
Output is correct |
93 |
Correct |
95 ms |
9200 KB |
Output is correct |
94 |
Correct |
96 ms |
9208 KB |
Output is correct |
95 |
Correct |
97 ms |
9232 KB |
Output is correct |
96 |
Correct |
95 ms |
9196 KB |
Output is correct |
97 |
Correct |
71 ms |
9208 KB |
Output is correct |
98 |
Correct |
69 ms |
9244 KB |
Output is correct |
99 |
Correct |
73 ms |
9224 KB |
Output is correct |
100 |
Correct |
93 ms |
9220 KB |
Output is correct |
101 |
Correct |
70 ms |
9284 KB |
Output is correct |
102 |
Correct |
73 ms |
9232 KB |
Output is correct |
103 |
Correct |
73 ms |
9292 KB |
Output is correct |
104 |
Correct |
73 ms |
9300 KB |
Output is correct |
105 |
Correct |
80 ms |
9200 KB |
Output is correct |
106 |
Correct |
70 ms |
9248 KB |
Output is correct |