Submission #516147

# Submission time Handle Problem Language Result Execution time Memory
516147 2022-01-20T12:55:46 Z thanh913 Cipele (COCI18_cipele) C++14
18 / 90
41 ms 1860 KB
#include <bits/stdc++.h>
using namespace std;

//types
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>

#define fi first
#define se second
#define inf 0x3f3f3f3f
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)

//lowercase 31, all 53
//(P/Q) % M = (P % M) * (Q^(M-2) % M)
//-------------------------------------------------------

const ll mx = 1e5+5, mod = 1e9+7;
ll n, m, a[mx], b[mx];

bool check(ll x)
{
	ll i = n, j = m;
	while (i >= 1) 
	{
		if (j < 1) return false;
		while (j >= 1) 
		{
			if (abs(b[i] - a[j]) <= x) 
			{
				j--;
				break;
			}
			else
				j--;
		}
		i--;
	}
	return true;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) cin >> b[i];
    sort(a+1, a+n+1);
	sort(b+1, b+n+1);
    ll l = 0, r = 1e9, kq = 1e9;
	while (l <= r) 
	{
		ll mid = (l+r) / 2;
		if (check(mid)) 
		{
			r = mid - 1;
			kq = mid;
		}
		else 
			l = mid + 1;
	}
	cout << kq;
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1836 KB Output is correct
2 Correct 34 ms 1796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 1860 KB Output is correct
2 Correct 36 ms 1824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Incorrect 2 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 1472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 1612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1528 KB Output isn't correct
2 Halted 0 ms 0 KB -