Re: [algogeeks] GREGOVIA in SPOJ

2017-11-25 Thread bujji jajala
hi Mehdi, Why should we consider from left to right only or right to left only ? Explanation you gave does not look like proof that it gives optimal solution. We should be able to prove that any other matching strategy is not better than greedy approach mentioned. The example I

Re: [algogeeks] GREGOVIA in SPOJ

2017-11-17 Thread MeHdi KaZemI
The Greedy observation is something like this: the leftmost person needs to satisfy his/her requirement from someone on his right, (i.e. if he wants to sell he has to sell to someone on his right, if he needs to buy he has to buy from someone on his right) Try to traverse the street from left to

[algogeeks] GREGOVIA in SPOJ

2017-11-16 Thread bujji jajala
Hi, I am trying to solve this problem in spoj website. you might be aware of this website. http://www.spoj.com/problems/GERGOVIA Gergovia consists of one street, and every inhabitant of the city is a wine salesman. Everyone buys wine from other inhabitants of the city. Every day each