Submission #716170

# Submission time Handle Problem Language Result Execution time Memory
716170 2023-03-29T07:34:18 Z amunduzbaev Wish (LMIO19_noras) C++17
38 / 100
1000 ms 5264 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;
		
		for(int i=T + 1;i<mx;i++){
			assert(check(i - 1) <= check(i));
		}
		for(int i=T-1;i>=0;i--){
			assert(check(i + 1) <= check(i));
		}
		
		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 82 ms 392 KB Output is correct
4 Correct 88 ms 396 KB Output is correct
5 Correct 84 ms 400 KB Output is correct
6 Correct 81 ms 400 KB Output is correct
7 Correct 86 ms 400 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 2 ms 324 KB Output is correct
14 Correct 84 ms 404 KB Output is correct
15 Correct 84 ms 404 KB Output is correct
16 Correct 81 ms 408 KB Output is correct
17 Correct 94 ms 404 KB Output is correct
18 Correct 91 ms 400 KB Output is correct
19 Correct 81 ms 396 KB Output is correct
20 Correct 85 ms 400 KB Output is correct
21 Correct 84 ms 408 KB Output is correct
22 Correct 90 ms 412 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 82 ms 392 KB Output is correct
4 Correct 88 ms 396 KB Output is correct
5 Correct 84 ms 400 KB Output is correct
6 Correct 81 ms 400 KB Output is correct
7 Correct 86 ms 400 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 2 ms 324 KB Output is correct
14 Correct 84 ms 404 KB Output is correct
15 Correct 84 ms 404 KB Output is correct
16 Correct 81 ms 408 KB Output is correct
17 Correct 94 ms 404 KB Output is correct
18 Correct 91 ms 400 KB Output is correct
19 Correct 81 ms 396 KB Output is correct
20 Correct 85 ms 400 KB Output is correct
21 Correct 84 ms 408 KB Output is correct
22 Correct 90 ms 412 KB Output is correct
23 Execution timed out 1071 ms 5264 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# 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 82 ms 392 KB Output is correct
4 Correct 88 ms 396 KB Output is correct
5 Correct 84 ms 400 KB Output is correct
6 Correct 81 ms 400 KB Output is correct
7 Correct 86 ms 400 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 2 ms 324 KB Output is correct
14 Correct 84 ms 404 KB Output is correct
15 Correct 84 ms 404 KB Output is correct
16 Correct 81 ms 408 KB Output is correct
17 Correct 94 ms 404 KB Output is correct
18 Correct 91 ms 400 KB Output is correct
19 Correct 81 ms 396 KB Output is correct
20 Correct 85 ms 400 KB Output is correct
21 Correct 84 ms 408 KB Output is correct
22 Correct 90 ms 412 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 90 ms 396 KB Output is correct
25 Correct 94 ms 460 KB Output is correct
26 Correct 87 ms 464 KB Output is correct
27 Correct 89 ms 408 KB Output is correct
28 Correct 92 ms 388 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 82 ms 392 KB Output is correct
4 Correct 88 ms 396 KB Output is correct
5 Correct 84 ms 400 KB Output is correct
6 Correct 81 ms 400 KB Output is correct
7 Correct 86 ms 400 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 2 ms 324 KB Output is correct
14 Correct 84 ms 404 KB Output is correct
15 Correct 84 ms 404 KB Output is correct
16 Correct 81 ms 408 KB Output is correct
17 Correct 94 ms 404 KB Output is correct
18 Correct 91 ms 400 KB Output is correct
19 Correct 81 ms 396 KB Output is correct
20 Correct 85 ms 400 KB Output is correct
21 Correct 84 ms 408 KB Output is correct
22 Correct 90 ms 412 KB Output is correct
23 Execution timed out 1071 ms 5264 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# 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 82 ms 392 KB Output is correct
4 Correct 88 ms 396 KB Output is correct
5 Correct 84 ms 400 KB Output is correct
6 Correct 81 ms 400 KB Output is correct
7 Correct 86 ms 400 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 2 ms 324 KB Output is correct
14 Correct 84 ms 404 KB Output is correct
15 Correct 84 ms 404 KB Output is correct
16 Correct 81 ms 408 KB Output is correct
17 Correct 94 ms 404 KB Output is correct
18 Correct 91 ms 400 KB Output is correct
19 Correct 81 ms 396 KB Output is correct
20 Correct 85 ms 400 KB Output is correct
21 Correct 84 ms 408 KB Output is correct
22 Correct 90 ms 412 KB Output is correct
23 Execution timed out 1071 ms 5264 KB Time limit exceeded
24 Halted 0 ms 0 KB -