KuzzR

pizdec_slovari

Oct 18th, 2021
591
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. m = int(input()) #num of ingridients
  2. ing = dict() #list of ingridients
  3. for i in range(m):
  4.     x = input().split(" ")
  5.     ing[x[0]] = int(x[1])
  6.  
  7. n = int(input()) #num of recepies
  8. recepies = dict()
  9. recepy = []
  10. for i in range(n):
  11.     x = input().split(" ")
  12.     k = int(x[1])
  13.     recepy.append([])
  14.     for j in range(k):
  15.         recepy[i].append(input().split(" "))
  16.     recepies[x[0]] = i
  17.  
  18. #print(recepies['lemonade'])
  19.  
  20. k = int(input()) #num of orders
  21. orders = []
  22. for i in range(k):
  23.     orders.append(input().split("\r")[0])
  24. #print(orders)
  25.  
  26.  
  27. for l in range(k+1):
  28.     if l != 0:
  29.         #print(recepies[orders[k-1]][0][0][0])
  30.         #print(orders[l-1])
  31.         for i in range(len(recepy[recepies[orders[l-1]]])):
  32.             #print(len(recepy[recepies[orders[k-1]]]))
  33.             #print(ing[recepy[recepies[orders[k-1]]]][i][0])
  34.             #print(recepy[recepies[orders[k-1]]][i][1])
  35.             #print(recepy[recepies[orders[l-1]]][i][1])
  36.             #print(ing[recepy[recepies[orders[l-1]]][i][0]])
  37.             x = ing[recepy[recepies[orders[l-1]]][i][0]]
  38.             ing[recepy[recepies[orders[l-1]]][i][0]] = x - int(recepy[recepies[orders[l-1]]][i][1])
  39.            
  40.     counter = 0
  41.     isPossible = True
  42.     for i in range(n):
  43.         isPossible = True
  44.         for j in range(len(recepy[i])):
  45.             if ing[recepy[i][j][0]] < int(recepy[i][j][1]):
  46.                 isPossible = False
  47.                 break
  48.         if isPossible == True:
  49.             counter += 1
  50.     print(counter)
  51.    
  52.  
RAW Paste Data