fork download
  1. import sys
  2.  
  3. while True:
  4. try:
  5. size = int(input())
  6. row1 = list(map(int,input().split()))
  7. row2 = list(map(int,input().split()))
  8. except EOFError:
  9. break
  10.  
  11. max = 0
  12. key = {}
  13. for i in row1:
  14. key[i] = 1
  15. for i in row2:
  16. if i in key:
  17. row1.remove(i)
  18. row2.remove(i)
  19. if i > max:
  20. max = i
  21.  
  22. if len(row1) > 0:
  23. for i in range(1 + len(row1)//2):
  24. t = min(row1)
  25. indices = [i for i,x in enumerate(row1) if x == t]
  26. if not indices[1] - indices[0] == 1:
  27. row1.remove(t)
  28. row1.remove(t)
  29. if t > max:
  30. max = t
  31. if len(row2) > 0:
  32. for j in range(1 + len(row2)//2):
  33. t = min(row2)
  34. indices = [i for i,x in enumerate(row2) if x == t]
  35. if not indices[1] - indices[0] == 1:
  36. row2.remove(t)
  37. row2.remove(t)
  38. if t > max:
  39. max = t
  40. print (max)
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
Runtime error #stdin #stdout #stderr 0.02s 28384KB
stdin
5
1 2 3 4 5
1 2 3 4 5
8
7 7 15 15 2 2 4 4
5 5 3 3 9 9 1 1
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 26, in <module>
IndexError: list index out of range