Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
0.5s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Given a sequence of ~n~ sorted integers ~a_0, a_1, .. , a_{n-1}~ and a positive integer ~k~, find the position ~i~ such that ~a_i~ is the largest number that is less than or equal to k. If no such number exists, return -1. If there are multiple valid positions i, choose the largest one.
INPUT
- Line 1: Two integers, ~n~ and ~k~.
- Line 2: n integers, ~a_0, a_1, .. , a_{n-1}~
OUTPUT
- The position i found
CONSTRAINTS
- ~1 \leq n \leq 10^4~
- ~-10^4 \leq k, a_i \leq 10^4~
INPUT
4 5
1 3 5 6
OUTPUT
2
Bình luận