The questions is
There is a country with n citizens. The i-th of them initially has ai
money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have.
Sometimes the government makes payouts to the poor: all citizens who have strictly less money than x
are paid accordingly so that after the payout they have exactly x
money. In this case the citizens don’t send a receipt.
You know the initial wealth of every citizen and the log of all events: receipts and payouts. Restore the amount of money each citizen has after all events.
My code for the questions is ,
def fun(l,a,n):
for i in range(n):
if a[i]<=l[1]:
a[i]=l[1]
def fun2(l,a,n):
a[l[1]-1]=l[2]
n=int(input())
a=list(map(int,input().split()))
#q=int(input())
for _ in range(int(input())):
l=list(map(int,input().split()))
if l[0]==2:
fun(l,a,n)
else:
fun2(l,a,n)
print(*a)
but my code is exceeding time limit ,any suggestions or improvement in the code.?