-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathairconditioned.py
48 lines (40 loc) · 1.27 KB
/
airconditioned.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
minions = int(input(""))
test = False
temps = []
if not test:
for i in range(minions):
first, second = map(int, input().split(" "))
temps.append([])
temps[i].append(first)
temps[i].append(second)
for i in range(len(temps)):
temps[i] = sorted(temps[i])
def first(temp):
return temp[0] + temp[1]
temps.sort(key=first)
#print(temps)
deletions = 0
for i in range(len(temps)):
#print(temps[i - deletions])
try:
#print("Comparing {} with {}".format(temps[i - deletions][1], temps[i - deletions + 1][0]))
if temps[i - deletions][1] >= temps[i - deletions + 1][0]:
temps[i - deletions + 1][1] = temps[i - deletions][1]
#print("Removed {}".format(temps[i - deletions]))
temps.remove(temps[i - deletions])
deletions += 1
#print(temps)
except IndexError:
pass
try:
if temps[i - deletions][1] == temps[i - deletions + 1][0]:
temps.remove(item)
except:
pass
print(len(temps))
#[2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3]
#[2, 5], [3, 6], [4, 7], [5, 8]
#[4, 2], [2, 1], [6, 5],
#[2, 3], [3, 7], [4, 5], [5, 6]
#[2, 2], [2, 3], [3, 3], [4, 4]
#[3, 6], [3, 3], [4, 5]