# 2017 December Bronze Milk Measurement

I’ve tried to debug, but my code still only passes on test cases 1,5, and 6.
My method is to simulate through Farmer John’s log after sorting it, and if we change the pictures, increment answer by 1. This works for the sample test case and 2 other cases, but doesn’t pass all other test cases.

Am I miscalculating the number of adjustments Farmer John has to make?

here’s the code:

``````N = int(input())
log = []
milks = [7,7,7]  #Bessie,Elsie,Mildred

for _ in range(N):
day, name, milk = map(str,input().split())
day,milk = int(day),int(milk)
log.append([day,name,milk])

#sort Farmer John's log/notes
log.sort(key=lambda x: x)

cnt = 0

curCowMax = ["Bessie","Elsie","Mildred"] #current pictures of cows

for i in range(N):
cnt = 0
#update milk amounts
if log[i] == "Bessie":
milks += log[i]
elif log[i] == "Elsie":
milks += log[i]
else: #Mildred
milks += log[i]

maxAmt = max(milks)
for j in range(3):  #I did something wrong here, but idk what went wrong

if (milks[j] == maxAmt and log[j] not in curCowMax):
curCowMax.append(log[j])
cnt += 1
if (milks[j] < maxAmt and log[j] in curCowMax):
curCowMax.remove(log[j])
cnt += 1

if cnt!= 0: #if farmer john has to change the pics
ans += 1

print(ans)
``````

Thanks!