2017 December Bronze Milk Measurement

I’ve tried to debug, but my code still only passes on test cases 1,5, and 6.
problem link: USACO
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

#read inputs
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[0])

cnt = 0 
ans= 0 #answer

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

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

  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][1] not in curCowMax):
      curCowMax.append(log[j][1])
      cnt += 1
    if (milks[j] < maxAmt and log[j][1] in curCowMax):
      curCowMax.remove(log[j][1])
      cnt += 1
      
  if cnt!= 0: #if farmer john has to change the pics
    ans += 1
    
print(ans)

Thanks!

Have you tried downloading the test cases?

I tried downloading them, but I can’t open the .in or .out files.

What seems to be the problem? Any standard text editor like VSC or even Notepad should be able to handle them.

It doesn’t give me an option to open it. I’ll try to open it later on a different device! Once I open it, do I just try to debug and see what went wrong in my code?

Thanks!

Yeah.