Compute Chokepoint
You are the only tech guy at a government contractor working a (
am to
pm,
days a week), and you have just been asked to set up a service to send network messages. However, the network switch is from
and there is no budget for a new one. There is a handwritten note next to the switch that says it will catch fire if more than
network requests are sent in
seconds.
Thus, you must make a network gateway that will only forward messages if they wouldn't cause the switch to catch fire. If the request would cause the number to go over the limit, too bad for them... they can figure out how to resend it or hotspot from their phones or something.
Input
The first line contains an integer , the number of network messages you will receive.
The next lines each contain an integer
, the time that the
th message is sent. These will be given in non-decreasing order.
Output
For each of the inputted messages, you should decide whether to accept or deny the message in order to fulfill the requirement of sending no more than messages every
seconds.
You should output lines and, if a message would cause more than
messages in
seconds to be sent, print "DENIED". Otherwise, print "ACCEPTED".
Examples
Input 1
8
1
3
4
7
8
10
12
13
Output 1
ACCEPTED
ACCEPTED
ACCEPTED
ACCEPTED
ACCEPTED
DENIED
ACCEPTED
DENIED
When we get to the message sent at time , there have already been
messages sent in the first
seconds so we must deny it. However, by the time we get to
, the message sent at
was more than
seconds ago, so we can accept this message. Due to this, the next message at
cannot be accepted as there have now been
messages sent since
.
Input 2
6
1
2
3
4
5
12
Output 2
ACCEPTED
ACCEPTED
ACCEPTED
ACCEPTED
ACCEPTED
ACCEPTED
By the time comes along,
was more than
seconds ago, so we are fine to accept all these messages.
Comments