Казантаев Алексей 619/2 UniInterval 3300 | Уразметова Маргарита Руслановна, группа 341/2 UniInterval 2613 | ||||
---|---|---|---|---|---|
f | 1 | a = eval(input()) | f | 1 | a = eval(input()) |
2 | n = len(a) | 2 | n = len(a) | ||
n | 3 | x = [(a[i][0], False) for i in range(n)] + [(a[i][1], True) for i in range(n)] | n | 3 | pair = [(a[i][0], False) for i in range(n)] + [(a[j][1], True) for j in range(n)] |
4 | x.sort() | 4 | pair.sort() | ||
5 | result = 0 | 5 | result = 0 | ||
6 | c = 0 | 6 | c = 0 | ||
7 | for i in range(n * 2): | 7 | for i in range(n * 2): | ||
8 | if c and i: | 8 | if c and i: | ||
t | 9 | result += x[i][0] - x[i - 1][0] | t | 9 | result += pair[i][0] - pair[i - 1][0] |
10 | if x[i][1]: | 10 | if pair[i][1]: | ||
11 | c += 1 | 11 | c += 1 | ||
12 | else: | 12 | else: | ||
13 | c -= 1 | 13 | c -= 1 | ||
14 | print(result) | 14 | print(result) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|