Submission #716173

# Submission time Handle Problem Language Result Execution time Memory
716173 2023-03-29T07:41:49 Z amunduzbaev Wish (LMIO19_noras) C++17
93 / 100
210 ms 21196 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 = 3e4;
int a[N], b[N], c[N], d[N];
int l_[N], r_[N];
 
signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int 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());
	int 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 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 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 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 1 ms 468 KB Output is correct
15 Correct 1 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 472 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 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 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 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 1 ms 468 KB Output is correct
15 Correct 1 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 472 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 59 ms 9216 KB Output is correct
24 Correct 59 ms 10784 KB Output is correct
25 Correct 60 ms 10776 KB Output is correct
26 Correct 59 ms 10772 KB Output is correct
27 Correct 59 ms 11060 KB Output is correct
28 Correct 62 ms 10888 KB Output is correct
29 Correct 60 ms 10996 KB Output is correct
30 Correct 63 ms 10988 KB Output is correct
31 Correct 57 ms 10940 KB Output is correct
32 Correct 74 ms 10948 KB Output is correct
33 Correct 79 ms 10956 KB Output is correct
34 Correct 79 ms 10908 KB Output is correct
35 Correct 75 ms 10944 KB Output is correct
36 Correct 75 ms 10948 KB Output is correct
37 Correct 57 ms 10780 KB Output is correct
38 Correct 60 ms 10804 KB Output is correct
39 Correct 61 ms 10764 KB Output is correct
40 Correct 69 ms 10812 KB Output is correct
41 Correct 60 ms 10808 KB Output is correct
42 Correct 61 ms 11072 KB Output is correct
43 Correct 180 ms 21196 KB Output is correct
44 Correct 182 ms 17984 KB Output is correct
45 Correct 172 ms 18000 KB Output is correct
46 Correct 173 ms 18016 KB Output is correct
47 Correct 210 ms 17956 KB Output is correct
48 Correct 148 ms 17984 KB Output is correct
49 Correct 148 ms 18048 KB Output is correct
50 Correct 157 ms 17992 KB Output is correct
51 Correct 154 ms 17984 KB Output is correct
52 Correct 146 ms 18000 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 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 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 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 1 ms 468 KB Output is correct
15 Correct 1 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 472 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 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 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 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 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 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 1 ms 468 KB Output is correct
15 Correct 1 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 472 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 59 ms 9216 KB Output is correct
24 Correct 59 ms 10784 KB Output is correct
25 Correct 60 ms 10776 KB Output is correct
26 Correct 59 ms 10772 KB Output is correct
27 Correct 59 ms 11060 KB Output is correct
28 Correct 62 ms 10888 KB Output is correct
29 Correct 60 ms 10996 KB Output is correct
30 Correct 63 ms 10988 KB Output is correct
31 Correct 57 ms 10940 KB Output is correct
32 Correct 74 ms 10948 KB Output is correct
33 Correct 79 ms 10956 KB Output is correct
34 Correct 79 ms 10908 KB Output is correct
35 Correct 75 ms 10944 KB Output is correct
36 Correct 75 ms 10948 KB Output is correct
37 Correct 57 ms 10780 KB Output is correct
38 Correct 60 ms 10804 KB Output is correct
39 Correct 61 ms 10764 KB Output is correct
40 Correct 69 ms 10812 KB Output is correct
41 Correct 60 ms 10808 KB Output is correct
42 Correct 61 ms 11072 KB Output is correct
43 Correct 180 ms 21196 KB Output is correct
44 Correct 182 ms 17984 KB Output is correct
45 Correct 172 ms 18000 KB Output is correct
46 Correct 173 ms 18016 KB Output is correct
47 Correct 210 ms 17956 KB Output is correct
48 Correct 148 ms 17984 KB Output is correct
49 Correct 148 ms 18048 KB Output is correct
50 Correct 157 ms 17992 KB Output is correct
51 Correct 154 ms 17984 KB Output is correct
52 Correct 146 ms 18000 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
54 Correct 1 ms 468 KB Output is correct
55 Correct 1 ms 468 KB Output is correct
56 Correct 1 ms 468 KB Output is correct
57 Correct 1 ms 468 KB Output is correct
58 Correct 1 ms 468 KB Output is correct
59 Correct 59 ms 9228 KB Output is correct
60 Correct 63 ms 9244 KB Output is correct
61 Correct 62 ms 9228 KB Output is correct
62 Correct 59 ms 9156 KB Output is correct
63 Correct 76 ms 9140 KB Output is correct
64 Correct 75 ms 9328 KB Output is correct
65 Correct 69 ms 9228 KB Output is correct
66 Correct 72 ms 9284 KB Output is correct
67 Correct 68 ms 9224 KB Output is correct
68 Correct 84 ms 9260 KB Output is correct
69 Correct 82 ms 9172 KB Output is correct
70 Correct 80 ms 9208 KB Output is correct
71 Correct 73 ms 9276 KB Output is correct
72 Correct 78 ms 9248 KB Output is correct
73 Correct 56 ms 9300 KB Output is correct
74 Correct 55 ms 9224 KB Output is correct
75 Correct 56 ms 9288 KB Output is correct
76 Correct 55 ms 9252 KB Output is correct
77 Correct 159 ms 18004 KB Output is correct
78 Correct 197 ms 17960 KB Output is correct
79 Correct 164 ms 18004 KB Output is correct
80 Correct 165 ms 18132 KB Output is correct
81 Correct 163 ms 17988 KB Output is correct
82 Correct 165 ms 18012 KB Output is correct
83 Correct 150 ms 17980 KB Output is correct
84 Correct 170 ms 18004 KB Output is correct
85 Correct 160 ms 18052 KB Output is correct
86 Correct 156 ms 17960 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 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 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 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 1 ms 468 KB Output is correct
15 Correct 1 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 472 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 59 ms 9216 KB Output is correct
24 Correct 59 ms 10784 KB Output is correct
25 Correct 60 ms 10776 KB Output is correct
26 Correct 59 ms 10772 KB Output is correct
27 Correct 59 ms 11060 KB Output is correct
28 Correct 62 ms 10888 KB Output is correct
29 Correct 60 ms 10996 KB Output is correct
30 Correct 63 ms 10988 KB Output is correct
31 Correct 57 ms 10940 KB Output is correct
32 Correct 74 ms 10948 KB Output is correct
33 Correct 79 ms 10956 KB Output is correct
34 Correct 79 ms 10908 KB Output is correct
35 Correct 75 ms 10944 KB Output is correct
36 Correct 75 ms 10948 KB Output is correct
37 Correct 57 ms 10780 KB Output is correct
38 Correct 60 ms 10804 KB Output is correct
39 Correct 61 ms 10764 KB Output is correct
40 Correct 69 ms 10812 KB Output is correct
41 Correct 60 ms 10808 KB Output is correct
42 Correct 61 ms 11072 KB Output is correct
43 Correct 180 ms 21196 KB Output is correct
44 Correct 182 ms 17984 KB Output is correct
45 Correct 172 ms 18000 KB Output is correct
46 Correct 173 ms 18016 KB Output is correct
47 Correct 210 ms 17956 KB Output is correct
48 Correct 148 ms 17984 KB Output is correct
49 Correct 148 ms 18048 KB Output is correct
50 Correct 157 ms 17992 KB Output is correct
51 Correct 154 ms 17984 KB Output is correct
52 Correct 146 ms 18000 KB Output is correct
53 Correct 59 ms 9228 KB Output is correct
54 Correct 63 ms 9244 KB Output is correct
55 Correct 62 ms 9228 KB Output is correct
56 Correct 59 ms 9156 KB Output is correct
57 Correct 76 ms 9140 KB Output is correct
58 Correct 75 ms 9328 KB Output is correct
59 Correct 69 ms 9228 KB Output is correct
60 Correct 72 ms 9284 KB Output is correct
61 Correct 68 ms 9224 KB Output is correct
62 Correct 84 ms 9260 KB Output is correct
63 Correct 82 ms 9172 KB Output is correct
64 Correct 80 ms 9208 KB Output is correct
65 Correct 73 ms 9276 KB Output is correct
66 Correct 78 ms 9248 KB Output is correct
67 Correct 56 ms 9300 KB Output is correct
68 Correct 55 ms 9224 KB Output is correct
69 Correct 56 ms 9288 KB Output is correct
70 Correct 55 ms 9252 KB Output is correct
71 Correct 159 ms 18004 KB Output is correct
72 Correct 197 ms 17960 KB Output is correct
73 Correct 164 ms 18004 KB Output is correct
74 Correct 165 ms 18132 KB Output is correct
75 Correct 163 ms 17988 KB Output is correct
76 Correct 165 ms 18012 KB Output is correct
77 Correct 150 ms 17980 KB Output is correct
78 Correct 170 ms 18004 KB Output is correct
79 Correct 160 ms 18052 KB Output is correct
80 Correct 156 ms 17960 KB Output is correct
81 Correct 0 ms 340 KB Output is correct
82 Correct 1 ms 468 KB Output is correct
83 Correct 1 ms 468 KB Output is correct
84 Correct 1 ms 468 KB Output is correct
85 Correct 1 ms 468 KB Output is correct
86 Correct 1 ms 468 KB Output is correct
87 Incorrect 66 ms 9316 KB Output isn't correct
88 Halted 0 ms 0 KB -