#CCBCHBAHAI0000156. Tìm vị trí xuất hiện cuối cùng của x (Last Position of x)
Tìm vị trí xuất hiện cuối cùng của x (Last Position of x)
Last Position of x
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer array and an integer , find the largest -based index such that .
If no such index exists, print -1.
Input
- The first line contains integers and .
- The second line contains integers .
Output
Print the last index of , or -1 if does not occur.
Subtasks
Subtask 1 (100 points): ; .
Examples
Input
7 5
2 5 3 5 8 5 1
Output
5
Explanation
Value occurs at indices . The largest is .