Jon Snow vs Daenerys targaryen

0

0 votes
Binary Search, Sorting, medium, Easy
Problem

Jon Snow and Daenerys Targaryen are playing a game to kill white-walkers. More white-walkers they kill, more power of Night King will be decreased. They need to destroy n white-walkers to decrease the certain level of strength of Night King. Jon's Dragon performs an attack with u hits per second of fire and Daenerys's Dragon performs an attack with v hits per second of fire. Each Dragon spends the fixed time to raise fire (Jon's Dragon spends 1/u seconds to fire and Daenerys Dragon spends 1/v seconds to fire). The ith white-walker dies after he receives ai hits of fire.

Jon and Daenerys wonder who makes the last hit on each white-walker. If Jon and Daenerys make the last hit at the same time, we assume that both of them have made the last hit. 

Input:

  • The first line contains three integer  n, u, v (1 <= n <= 105 , 1 <= u, v <= 106) - the number of white-walkers, the amount of fire of Jon's and Daenerys's attack, respectively.
  • Next n lines contains integers  a(1 <= a<=10^9) - the number of hits needed to destroy the ith  white-walker.

Output:

  • Print n lines. In the ith line print word "Jon Snow" - if the last hit on the ith white-walker was performed by Jon, "Daenerys Targaryen"- if Daenerys performed the last hit, or "Both"- if both performed it at the same time.
Time Limit: 0.5
Memory Limit: 256
Source Limit:
Explanation

In the sample test case Jon makes the first hit at time 1 / 3, Daenerys makes the second hit at time 1 / 2, Jon makes the third hit at time 2 / 3, and both make the fourth and fifth hit simultaneously at the time 1.

Editor Image

?