human
Check if all people can vote on two machines | Returns true if n people can vote using two machines in x time ..
calculate total sum i . e total time taken by all people.
if total time is less than x then all people can definitely vote hence return true.
sort the list.
declare a list presum of same size as that of a and initialize it with 0.
prefixsum for first element will be element itself.
fill the array.
Set i and j and check if array from i to j - 1 gives sum <= x.
Driver code"
Solution in Python:

What is a code to check if all people can vote on two machines and the other steps required?
assistant
#Here is code to check if all people can vote on two machines and the other steps required.
 def canVote ( a , n , x ) :
	total_sum = 0
	for i in range ( len ( a ) ) :
		total_sum += a [ i ]
	if ( total_sum <= x ) :
		return True
	a . sort ( )
	presum = [ 0 for i in range ( len ( a ) ) ]
	presum [ 0 ] = a [ 0 ]
	for i in range ( 1 , len ( presum ) ) :
		presum [ i ] = presum [ i - 1 ] + a [ i ]
	for i in range ( 0 , len ( presum ) ) :
		for j in range ( i + 1 , len ( presum ) ) :
			arr1_sum = ( presum [ i ] + ( total_sum - presum [ j ] ) )
			if ( ( arr1_sum <= x ) and ( total_sum - arr1_sum ) <= x ) :
				return True
	return False
n = 3
x = 4
a = [ 2 , 4 , 2 ]
if ( canVote ( a , n , x ) ) :
	print ( " YES " )
else :
	print ( " NO " )