The recent experience from the local elections showed that the procedure consisting of one or maximum two rounds is really [url removed, login to view] the european council decided that setting up elections in the middle of the economical crisis is an unnecessary [url removed, login to view] local elections will be replaced by another "success event" which is going to attract many tourists and make some money for every region of the [url removed, login to view] by a recent speech of a candidate "we are a new political party and we performed a race to end up in that position" it has been decided that the new elections procedure will be based on a true race with many [url removed, login to view] rules are the following: The route where the race is taking place is a circle with length L. One point of the route is chosen to be the starting/ending point. Every candidate out of the N takes his place in some distance D from the start,counted [url removed, login to view] the candidates are numbered from 1 to N,again clockwise, starting from the one closer to the right of the starting point. When the race starts every candidate runs clockwise with his own speed. If a candidate reaches another candidate, that was placed in front of him in the beginning, then the one that was in front quits the [url removed, login to view] elections race finishes when it's not possible for any candidate to [url removed, login to view] the candidates that haven't quitted at that point can be considered as winners.
-->The exercise wants you to write 2 programs (one in C or C++ AND one in SML/NJ or MLton or OCaml) that take as input the parameters of the elections race and return as output the turn that the candidates quit the race(based on their numbers). The input will be read from a file as the following [url removed, login to view] first line has two positive integers N and L(N <= 500.000 and L < [url removed, login to view] ). The i-th from the next N lines will have the parameters of the i-th candidate : the intger number D(i) ,which is 0<=D(1) <D(2)<...<D(N) <L , and the speed V(i) which is a float number with 2 digits after the comma ( 0< V(i)<= 5 ). Distances are given in meters and speeds in meters/seconds.
Constraints: Time: 10seconds Memory: 256MB
Above there are some examples in both C and ML:
> ./agonas [url removed, login to view]
2 3 5 4 6
- agonas "[url removed, login to view]";
val it = [2,3,5,4,6] : int list
where the input file is
> cat [url removed, login to view]
The winner of the elections race above is the first candidate, the one that begins from the starting/ending [url removed, login to view] that between different numbers in both input and output we have to leave a [url removed, login to view] program in SML/NJ must define a function with name agonas which will give us a list of integers as a return.