#NEWLINE# @ contract #NEWLINE# def minimum_migration_time_max_cpu( last_n , vms_cpu , vms_ram ) : #NEWLINE# #INDENT# ' Selects the VM with the minimum RAM and maximum CPU usage.\n\n    :param last_n: The number of last CPU utilization values to average.\n     :type last_n: int,>0\n\n    :param vms_cpu: A map of VM UUID and their CPU utilization histories.\n     :type vms_cpu: dict(str: list)\n\n    :param vms_ram: A map of VM UUID and their RAM usage data.\n     :type vms_ram: dict(str: number)\n\n    :return: A VM to migrate from the host.\n     :rtype: str\n    ' #NEWLINE# min_ram = min ( vms_ram . values ( ) ) #NEWLINE# max_cpu = 0 #NEWLINE# selected_vm = None #NEWLINE# for ( vm , cpu ) in vms_cpu . items ( ) : #NEWLINE# #INDENT# if ( vms_ram [ vm ] > min_ram ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# vals = cpu [ ( - last_n ) : ] #NEWLINE# avg = ( float ( sum ( vals ) ) / len ( vals ) ) #NEWLINE# if ( max_cpu < avg ) : #NEWLINE# #INDENT# max_cpu = avg #NEWLINE# selected_vm = vm #NEWLINE# #UNINDENT# #UNINDENT# return selected_vm