Submission #24679893


Source Code Expand

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

s = []
for v in a:
    s += [[v, 0]]
for w in b:
    s += [[w, 1]]
s = sorted(s)

res = 10 ** 10
left = 0
right = n + m - 1
for i in range(1, n + m):
    if right < i:
        left = right
        right = n + m - 1
    if s[i][1] == s[left][1]:
        left = i
    else:
        right = i
        res = min(res, s[right][0] - s[left][0])
#    print('i', i, left, right, 'res', res)

print(res)

Submission Info

Submission Time
Task C - Min Difference
User cubesat
Language Python (3.8.2)
Score 300
Code Size 525 Byte
Status AC
Exec Time 1581 ms
Memory 66868 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 20
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, small_00.txt, small_01.txt, small_02.txt, small_03.txt, small_04.txt
Case Name Status Exec Time Memory
example_00.txt AC 22 ms 9100 KiB
example_01.txt AC 25 ms 9228 KiB
example_02.txt AC 20 ms 9044 KiB
hand_00.txt AC 379 ms 59272 KiB
hand_01.txt AC 418 ms 64680 KiB
random_00.txt AC 1271 ms 66868 KiB
random_01.txt AC 1219 ms 66424 KiB
random_02.txt AC 1240 ms 63960 KiB
random_03.txt AC 1552 ms 66300 KiB
random_04.txt AC 1529 ms 66492 KiB
random_05.txt AC 1556 ms 65188 KiB
random_06.txt AC 1581 ms 66476 KiB
random_07.txt AC 1527 ms 66412 KiB
random_08.txt AC 1515 ms 65012 KiB
random_09.txt AC 1506 ms 66368 KiB
small_00.txt AC 43 ms 10292 KiB
small_01.txt AC 39 ms 10236 KiB
small_02.txt AC 41 ms 10228 KiB
small_03.txt AC 46 ms 10404 KiB
small_04.txt AC 26 ms 9384 KiB