#BS0000240. Sushi băng chuyền (Kaiten Sushi)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Sushi băng chuyền (Kaiten Sushi)
Kaiten Sushi
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are customers in order from to . Customer accepts sushi whose tastiness is at least . Each of the pieces, with tastiness for piece , passes the customers in increasing index order until the first customer willing to eat it takes it. Later customers cannot take that piece. Customers may eat multiple pieces. Determine the recipient of each piece, or report that no one takes it.
Input
The first line contains integers . The second contains integers . The third contains integers .
Output
Print lines: the recipient index for piece , or -1 if nobody takes it.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for all ; for .
- Subtask 3 (50 points): ; for every .
Examples
Input
4 4
6 9 3 1
9 3 2 1
Output
1
3
4
4
Explanation
The piece of tastiness 9 goes to customer 1. The piece of tastiness 3 passes customers 1 and 2 and goes to 3. Both remaining pieces pass the first three customers and go to 4.