PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000101. Vị trí gần nhất bên trái (Closest to the Left)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Vị trí gần nhất bên trái (Closest to the Left)
Closest to the Left
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a non-decreasing array , for each query output the largest one-based index with , or if none exists.
Input
The first line contains . The second contains sorted integers. The third contains queried integers.
Output
Print one-based indices (or ), in query order, separated by spaces.
Subtasks
- Subtask 1 (20 points): ; ; ; array is non-decreasing.
- Subtask 2 (30 points): ; ; ; array is non-decreasing.
- Subtask 3 (50 points): ; ; ; array is non-decreasing.
Examples
Input
5 5
1 3 3 4 10
3 2 11 0 4
Output
3 1 5 0 4
Explanation
For , entries qualify, so the last index is . For only entry qualifies. All five entries qualify for , none for , and the first four for . Thus the output is 3 1 5 0 4.