Posts

Mango Market

Image
  In a market of mangoes, there are   N N  sellers numbered from  1 1  to  N N . The  i i -th seller initially charges a price of  A i A i  coins for each of their mangoes. However, the sellers are very competitive, and they will change prices based on other sellers nearby. You have a simple graph (unweighted, undirected graph containing no self-loops or multiple edges)  G G  with  N N  vertices and  M M  edges. There is an edge between two sellers if and only if they are neighbours. When you buy a mango from a seller numbered  X X , the following occurs: Seller  X X  keeps his price the same. Every seller  Y Y  who is a neighbour of  X X  increases their price by  1 1 , that is,  A Y = A Y + 1 A Y = A Y + 1  for every  Y Y  who is a neighbour of  X X . Every other seller  Z Z  who is  not  a neighbour of  X X  decrease...