PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000102. Vị trí gần nhất bên phải (Closest to the Right)
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 phải (Closest to the Right)
Closest to the Right
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a non-decreasing array , report the smallest one-based index with . If none exists, output .
Input
The first line contains , followed by a line of sorted integers and a line of queries.
Output
Print the positions 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
2 2 6 1 4
Explanation
For targets and , the first qualifying position is ; exceeds every element so output ; qualifies at position ; first qualifies at position .