DPlayerGod's blog

By DPlayerGod, history, 3 years ago, In English

Hope someone will be able to give me an idea about this problem :

John has N movie discs placed in a stack, which are numbered 1, 2 ... n from the top. For every time he takes a disc, John will skillfully pull the disc he wants to watch from the stack. And after using it later, he put this plate on top again, messing up the order. Now he has m discs to watch in turn, where on the stack he wants to watch it each time he watches the ith disc ?

Sample Input

5 3
4 4 5

Sample Output

4 1 5 

Note : n, m <= 1e5.

Thank you so much!

Full text and comments »

  • Vote: I like it
  • -9
  • Vote: I do not like it