IX Olimpiada Informatyczna 2001/2002
|
Task: kol
|
Author: Tomasz Waleń
|
I stage contest |
Byteotian State Railways decided to keep up with the times and introduce to their offer an InterCity connection. Because of lack of efficient engines, clean carriages and straight tracks it was possible to establish only one such a connection. The lack of any computer system for seat reservation was another obstacle. Writing the main part of this system is your task.
For simplicity we assume that the InterCity connection runs through c cities numbered successively from 1 to c (the starting city has the number 1, and c is the number of the ending city). There are s seats in the train and transporting more passengers between any two successive stations is not allowed.
The computer system is to receive successive requests and determine whether they may be fulfilled. A request is accepted when in the given section of the railway line there is enough vacant seats in the train. Otherwise it is rejected. Partial accepting of a request is not allowed, e.g. for a part of a route or for less passengers. After accepting a request, the number of vacant seats in the train is updated. The requests are processed successively in the order of coming.
4 6 4 1 4 2 1 3 2 2 4 3 1 2 3the correct answer is in the following output file kol.out:
T T N N