Submission #858539

# Submission time Handle Problem Language Result Execution time Memory
858539 2023-10-08T16:55:32 Z serifefedartar Cipele (COCI18_cipele) C++17
54 / 90
33 ms 3412 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 998244353;
const ll LOGN = 18; 
const ll INF = 1e15;
const ll MAXN = 3e5 + 5;

int N, M;
vector<int> A, B;
bool check(int x) {
	int ptr = 0;
	for (int i = 0; i < N; i++) {
		while (abs(A[i] - B[ptr]) > x) {
			ptr++;
			if (ptr == M)
				return false;
		}
		ptr++;
	}
	return true;
}

int main() {
	fast
	cin >> N >> M;

	A = vector<int>(N);
	B = vector<int>(M);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	for (int i = 0; i < M; i++)
		cin >> B[i];
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());

	if (N > M) {
		swap(N, M);
		swap(A, B);
	}

	int L = 0;
	int R = 1e9;
	int ans = -1;
	while (R >= L) {
		int mid = L + (R-L)/2;
		if (check(mid)) {
			ans = mid;
			R = mid - 1;
		} else
			L = mid + 1;
	}
	cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 20 ms 2656 KB Output is correct
2 Correct 32 ms 3040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 2912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2368 KB Output is correct
2 Correct 19 ms 1812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 2940 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2484 KB Output is correct
2 Runtime error 28 ms 3412 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -