Hansrrr

URI 2065

Mar 24th, 2021 (edited)
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.19 KB | None | 0 0
  1. while(True):
  2.     try:
  3.        
  4.         employee, customers = input().split(" ")
  5.         employee = int(employee)
  6.         customers = int(customers)
  7.        
  8.         values1 = input()
  9.         valores = values1.split()
  10.         timeByEmployee = [int(valor) for valor in valores]
  11.  
  12.         values2 = input()
  13.         valor2 = values2.split()
  14.         itemsByCustomers =[int(valor) for valor in valor2]
  15.    
  16.  
  17.         tempoGasto = [None]*employee
  18.         count = 0
  19.         while(count < customers):
  20.             #verifica p ver ser tem gente esperando a ser atendida, se n tiver, entra no IF
  21.             if(count < employee):
  22.                 tempoGasto[count] = itemsByCustomers[count] * timeByEmployee[count]
  23.                 count+=1
  24.  
  25.             #Caso tenha alguem esperando:
  26.             # Nesse caso, vamos comparar os tempos com os outros funcionários, para ver qm esta livre
  27.  
  28.             else:
  29.                 print('2',tempoGasto)
  30.                 index = tempoGasto[0]
  31.                 count_2 = 0
  32.                 i = 0
  33.                 #nesse While verifica qual funcionario esta disponivel
  34.                 while(i < employee):
  35.                     #só entra nesse if se n tiver tempos iguais!
  36.                     if(index > tempoGasto[i]):
  37.                         index = tempoGasto[i]
  38.                         count_2 = i
  39.                     i+=1
  40.  
  41.                 print('3',tempoGasto)
  42.                 print('Funcionario disponível:', count_2+1)
  43.                 print('Cliente que será atendido:', count+1)
  44.                 #Assim, vamos somar o tempo gasto pelo funcionário mais atarefado + tempo do outro cliente
  45.                 #o count_2 passa a posicao do funcionario q esta disponivel
  46.                 tempoGasto[count_2] += itemsByCustomers[count] * timeByEmployee[count_2]
  47.                 count+=1
  48.                 count_2 = 0
  49.                
  50.         print('4',tempoGasto)
  51.         index = tempoGasto[0]
  52.         i=0
  53.         #aqui selecionamos o tempo mais alto gasto em tds as atividades
  54.         while(i < employee):
  55.             if(index < tempoGasto[i]):
  56.                 index = tempoGasto[i]
  57.             i+=1
  58.  
  59.         print(index)
  60.  
  61.  
  62.     except EOFError:
  63.         break
  64.  
Add Comment
Please, Sign In to add comment