Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- a = list(map(int, input().split()))
- to_sort = a[::2]
- not_sort = a[1::2]
- to_sort.sort()
- a = [0] * n
- for i in range(n // 2):
- a[i * 2] = to_sort[i]
- a[i * 2 + 1] = not_sort[i]
- if n % 2 == 1:
- a[-1] = to_sort[-1]
- print(*a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement