Submission #781023

# Submission time Handle Problem Language Result Execution time Memory
781023 2023-07-12T15:53:46 Z ymm Cipele (COCI18_cipele) C++17
90 / 90
33 ms 3676 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<ll> a(n), b(m);
	Loop (i,0,n)
		cin >> a[i];
	Loop (i,0,m)
		cin >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if (n > m) {
		swap(a, b);
		swap(n, m);
	}
	ll l = 0, r = 2e9;
	while (l < r) {
		ll mid = (l+r)/2;
		int p = 0;
		bool ok = 1;
		Loop (i,0,n) {
			while (p < m && abs(a[i] - b[p]) > mid)
				++p;
			if (p == m) {
				ok = 0;
				break;
			}
			++p;
		}
		if (ok)
			r = mid;
		else
			l = mid+1;
	}
	cout << l << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3416 KB Output is correct
2 Correct 33 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3676 KB Output is correct
2 Correct 33 ms 3668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3004 KB Output is correct
2 Correct 20 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3300 KB Output is correct
2 Correct 16 ms 2500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2976 KB Output is correct
2 Correct 28 ms 3188 KB Output is correct