Computer game, This is the Problem statement given in the techgig Platform.



The Problem Statement is Given:
Little Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the new game and needs to be updated. There are n video cards in the shop, the power of the i-th video card is equal to integer value ai. As Vlad wants to be sure the new game will work he wants to buy not one, but several video cards and unite their powers using the cutting-edge technology. To use this technology one of the cards is chosen as the leading one and other video cards are attached to it as secondary. For this new technology to work it's required that the power of each of the secondary video cards is divisible by the power of the leading video card. In order to achieve that the power of any secondary video card can be reduced to any integer value less or equal than the current power. However, the power of the leading video card should remain unchanged, i.e. it can't be reduced. Vlad has an infinite amount of money so he can buy any set of video cards. Help him determine which video cards he should buy such that after picking the leading video card and may be reducing some powers of others to make them work together he will get the maximum total value of video power.
Input Format
You will be given a function which contains an integer array that represents the number of video cards in the shop and powers of video cards.
Contraints
1<= n <= 200000 1 <= ai <= 10^4
Output Format
Return output which should contain one integer value the maximum possible total power of video cards working together.Explanation
It would be optimal to buy video cards with powers 3, 15 and 9. The video card with power 3 should be chosen as the leading one and all other video cards will be compatible with it. Thus, the total power would be 3 + 15 + 9 = 27. If he buys all the video cards and pick the one with the power 2 as the leading, the powers of all other video cards should be reduced by 1, thus the total power would be 2 + 2 + 14 + 8 = 26, that is less than 27. Please note, that it's not allowed to reduce the power of the leading video card, i.e. one can't get the total power 3+1+15+9=28.


CAUTION: First Try Your Self. This Is For Educational Purpose. Question Is Taken By Techgig Platform.

SOURCE: https://www.techgig.com/

CODE: Written In Python.

''' Read input from STDIN. Print your output to STDOUT '''
#Use input() to read input from STDIN and use print to write your output to STDOUT
import sys
def main():

# Write code here
k=[] #Create Empty List
new=[] #Create Second Empty List
d=[] #Create Third Empty List
N=int(input())
for i in sys.stdin:
k.append(i) #Append Input in String Format
k=[eval(x) for x in k] #String To Int
k.sort()
for i in range(N):
for j in range(N):
u=k[j]
while(u%k[i]!=0):
u=u-1
new.append(u)
d.append(sum(new))
new=[]
print(max(d))
main()
#This Blog Is Written By Upendra Charasiya. Contact:UpendraChaurasiya1998@gmail.com




#Practice_Makes_Codes_Perfect

Thank You For Giving Your Valuable Time.


Comments

Popular posts from this blog

GeeksforGeeks 2 October Problem: Enemy