Submission #716175

# Submission time Handle Problem Language Result Execution time Memory
716175 2023-03-29T07:46:11 Z amunduzbaev Wish (LMIO19_noras) C++17
100 / 100
337 ms 29480 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ar array
typedef long long ll;
#define int __int128
 
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 = [&](int x) -> __int128{
		return x * x;
	};
	
	for(int i=0;i<n;i++){
		auto check = [&](int 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 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 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 2 ms 468 KB Output is correct
17 Correct 2 ms 560 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 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 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 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 2 ms 468 KB Output is correct
17 Correct 2 ms 560 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 118 ms 14924 KB Output is correct
24 Correct 115 ms 14884 KB Output is correct
25 Correct 117 ms 14936 KB Output is correct
26 Correct 117 ms 14968 KB Output is correct
27 Correct 108 ms 15036 KB Output is correct
28 Correct 131 ms 14888 KB Output is correct
29 Correct 118 ms 15024 KB Output is correct
30 Correct 113 ms 14948 KB Output is correct
31 Correct 114 ms 14968 KB Output is correct
32 Correct 149 ms 14888 KB Output is correct
33 Correct 133 ms 14968 KB Output is correct
34 Correct 139 ms 14964 KB Output is correct
35 Correct 139 ms 14980 KB Output is correct
36 Correct 135 ms 14900 KB Output is correct
37 Correct 109 ms 14928 KB Output is correct
38 Correct 115 ms 14956 KB Output is correct
39 Correct 121 ms 14920 KB Output is correct
40 Correct 111 ms 14956 KB Output is correct
41 Correct 107 ms 14864 KB Output is correct
42 Correct 108 ms 14912 KB Output is correct
43 Correct 321 ms 29332 KB Output is correct
44 Correct 291 ms 29360 KB Output is correct
45 Correct 312 ms 29308 KB Output is correct
46 Correct 318 ms 29388 KB Output is correct
47 Correct 284 ms 29372 KB Output is correct
48 Correct 297 ms 29396 KB Output is correct
49 Correct 287 ms 29440 KB Output is correct
50 Correct 290 ms 29356 KB Output is correct
51 Correct 283 ms 29480 KB Output is correct
52 Correct 285 ms 29380 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 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 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 2 ms 468 KB Output is correct
17 Correct 2 ms 560 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 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 2 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 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 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 2 ms 468 KB Output is correct
17 Correct 2 ms 560 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 118 ms 14924 KB Output is correct
24 Correct 115 ms 14884 KB Output is correct
25 Correct 117 ms 14936 KB Output is correct
26 Correct 117 ms 14968 KB Output is correct
27 Correct 108 ms 15036 KB Output is correct
28 Correct 131 ms 14888 KB Output is correct
29 Correct 118 ms 15024 KB Output is correct
30 Correct 113 ms 14948 KB Output is correct
31 Correct 114 ms 14968 KB Output is correct
32 Correct 149 ms 14888 KB Output is correct
33 Correct 133 ms 14968 KB Output is correct
34 Correct 139 ms 14964 KB Output is correct
35 Correct 139 ms 14980 KB Output is correct
36 Correct 135 ms 14900 KB Output is correct
37 Correct 109 ms 14928 KB Output is correct
38 Correct 115 ms 14956 KB Output is correct
39 Correct 121 ms 14920 KB Output is correct
40 Correct 111 ms 14956 KB Output is correct
41 Correct 107 ms 14864 KB Output is correct
42 Correct 108 ms 14912 KB Output is correct
43 Correct 321 ms 29332 KB Output is correct
44 Correct 291 ms 29360 KB Output is correct
45 Correct 312 ms 29308 KB Output is correct
46 Correct 318 ms 29388 KB Output is correct
47 Correct 284 ms 29372 KB Output is correct
48 Correct 297 ms 29396 KB Output is correct
49 Correct 287 ms 29440 KB Output is correct
50 Correct 290 ms 29356 KB Output is correct
51 Correct 283 ms 29480 KB Output is correct
52 Correct 285 ms 29380 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
54 Correct 2 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 123 ms 14904 KB Output is correct
60 Correct 122 ms 14900 KB Output is correct
61 Correct 121 ms 14840 KB Output is correct
62 Correct 133 ms 14828 KB Output is correct
63 Correct 147 ms 14916 KB Output is correct
64 Correct 122 ms 14848 KB Output is correct
65 Correct 130 ms 14952 KB Output is correct
66 Correct 141 ms 14916 KB Output is correct
67 Correct 128 ms 14896 KB Output is correct
68 Correct 146 ms 14868 KB Output is correct
69 Correct 140 ms 14904 KB Output is correct
70 Correct 150 ms 14936 KB Output is correct
71 Correct 163 ms 14848 KB Output is correct
72 Correct 138 ms 14848 KB Output is correct
73 Correct 115 ms 14904 KB Output is correct
74 Correct 145 ms 14936 KB Output is correct
75 Correct 125 ms 14916 KB Output is correct
76 Correct 113 ms 14892 KB Output is correct
77 Correct 337 ms 29332 KB Output is correct
78 Correct 295 ms 29284 KB Output is correct
79 Correct 299 ms 29372 KB Output is correct
80 Correct 298 ms 29380 KB Output is correct
81 Correct 293 ms 29364 KB Output is correct
82 Correct 288 ms 29392 KB Output is correct
83 Correct 300 ms 29412 KB Output is correct
84 Correct 286 ms 29392 KB Output is correct
85 Correct 294 ms 29408 KB Output is correct
86 Correct 314 ms 29332 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 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 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 2 ms 468 KB Output is correct
17 Correct 2 ms 560 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 118 ms 14924 KB Output is correct
24 Correct 115 ms 14884 KB Output is correct
25 Correct 117 ms 14936 KB Output is correct
26 Correct 117 ms 14968 KB Output is correct
27 Correct 108 ms 15036 KB Output is correct
28 Correct 131 ms 14888 KB Output is correct
29 Correct 118 ms 15024 KB Output is correct
30 Correct 113 ms 14948 KB Output is correct
31 Correct 114 ms 14968 KB Output is correct
32 Correct 149 ms 14888 KB Output is correct
33 Correct 133 ms 14968 KB Output is correct
34 Correct 139 ms 14964 KB Output is correct
35 Correct 139 ms 14980 KB Output is correct
36 Correct 135 ms 14900 KB Output is correct
37 Correct 109 ms 14928 KB Output is correct
38 Correct 115 ms 14956 KB Output is correct
39 Correct 121 ms 14920 KB Output is correct
40 Correct 111 ms 14956 KB Output is correct
41 Correct 107 ms 14864 KB Output is correct
42 Correct 108 ms 14912 KB Output is correct
43 Correct 321 ms 29332 KB Output is correct
44 Correct 291 ms 29360 KB Output is correct
45 Correct 312 ms 29308 KB Output is correct
46 Correct 318 ms 29388 KB Output is correct
47 Correct 284 ms 29372 KB Output is correct
48 Correct 297 ms 29396 KB Output is correct
49 Correct 287 ms 29440 KB Output is correct
50 Correct 290 ms 29356 KB Output is correct
51 Correct 283 ms 29480 KB Output is correct
52 Correct 285 ms 29380 KB Output is correct
53 Correct 123 ms 14904 KB Output is correct
54 Correct 122 ms 14900 KB Output is correct
55 Correct 121 ms 14840 KB Output is correct
56 Correct 133 ms 14828 KB Output is correct
57 Correct 147 ms 14916 KB Output is correct
58 Correct 122 ms 14848 KB Output is correct
59 Correct 130 ms 14952 KB Output is correct
60 Correct 141 ms 14916 KB Output is correct
61 Correct 128 ms 14896 KB Output is correct
62 Correct 146 ms 14868 KB Output is correct
63 Correct 140 ms 14904 KB Output is correct
64 Correct 150 ms 14936 KB Output is correct
65 Correct 163 ms 14848 KB Output is correct
66 Correct 138 ms 14848 KB Output is correct
67 Correct 115 ms 14904 KB Output is correct
68 Correct 145 ms 14936 KB Output is correct
69 Correct 125 ms 14916 KB Output is correct
70 Correct 113 ms 14892 KB Output is correct
71 Correct 337 ms 29332 KB Output is correct
72 Correct 295 ms 29284 KB Output is correct
73 Correct 299 ms 29372 KB Output is correct
74 Correct 298 ms 29380 KB Output is correct
75 Correct 293 ms 29364 KB Output is correct
76 Correct 288 ms 29392 KB Output is correct
77 Correct 300 ms 29412 KB Output is correct
78 Correct 286 ms 29392 KB Output is correct
79 Correct 294 ms 29408 KB Output is correct
80 Correct 314 ms 29332 KB Output is correct
81 Correct 0 ms 340 KB Output is correct
82 Correct 2 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 135 ms 14936 KB Output is correct
88 Correct 136 ms 14916 KB Output is correct
89 Correct 162 ms 14896 KB Output is correct
90 Correct 140 ms 14916 KB Output is correct
91 Correct 133 ms 14864 KB Output is correct
92 Correct 141 ms 14804 KB Output is correct
93 Correct 162 ms 14928 KB Output is correct
94 Correct 144 ms 14888 KB Output is correct
95 Correct 143 ms 14900 KB Output is correct
96 Correct 145 ms 14880 KB Output is correct
97 Correct 137 ms 14936 KB Output is correct
98 Correct 122 ms 14884 KB Output is correct
99 Correct 139 ms 14888 KB Output is correct
100 Correct 131 ms 14852 KB Output is correct
101 Correct 139 ms 15036 KB Output is correct
102 Correct 122 ms 14944 KB Output is correct
103 Correct 122 ms 14848 KB Output is correct
104 Correct 132 ms 14892 KB Output is correct
105 Correct 140 ms 14864 KB Output is correct
106 Correct 126 ms 14884 KB Output is correct