CF999A.Mishka and Contest
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Mishka started participating in a programming contest. There are n problems in the contest. Mishka's problem-solving skill is equal to k.
Mishka arranges all problems from the contest into a list. Because of his weird principles, Mishka only solves problems from one of the ends of the list. Every time, he chooses which end (left or right) he will solve the next problem from. Thus, each problem Mishka solves is either the leftmost or the rightmost problem in the list.
Mishka cannot solve a problem with difficulty greater than k. When Mishka solves the problem, it disappears from the list, so the length of the list decreases by 1. Mishka stops when he is unable to solve any problem from any end of the list.
How many problems can Mishka solve?
米什卡开始参加一场编程竞赛。竞赛中共有 n 道题目,米什卡的解题能力为 k。
米什卡将竞赛中的所有题目按某种顺序排成一个列表。由于他奇特的原则,米什卡每次只从该列表的某一端(左端或右端)选取一道题目来解答。也就是说,他所解答的每道题目,必定是当前列表中最左边或最右边的题目。
米什卡无法解答难度大于 k 的题目。每当他解答完一道题目,该题目便从列表中移除,列表长度减 1。当米什卡无法从列表的任一端(左端或右端)解答任何题目时,他便停止解题。
请问:米什卡最多能解答多少道题目?
输入格式
The first line of input contains two integers n and k (1≤n,k≤100) — the number of problems in the contest and Mishka's problem-solving skill.
The second line of input contains n integers a1,a2,…,an (1≤ai≤100), where ai is the difficulty of the i-th problem. The problems are given in order from the leftmost to the rightmost in the list.
输入的第一行包含两个整数 n 和 k(1≤n,k≤100)—— 分别表示比赛中的题目数量和 Mishka 的解题能力。
输入的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤100),其中 ai 表示第 i 道题的难度。题目按从左到右的顺序给出。
输出格式
Print one integer — the maximum number of problems Mishka can solve.
输出一个整数——Mishka 最多能解决的问题数量。
输入输出样例
输入#1
8 4 4 2 3 1 5 1 6 4
输出#1
5
输入#2
5 2 3 1 2 1 3
输出#2
0
输入#3
5 100 12 34 55 43 21
输出#3
5
说明/提示
In the first example, Mishka can solve problems in the following order: [4,2,3,1,5,1,6,4]→[2,3,1,5,1,6,4]→[2,3,1,5,1,6]→[3,1,5,1,6]→[1,5,1,6]→[5,1,6], so the number of solved problems will be equal to 5.
In the second example, Mishka can't solve any problem because the difficulties of problems from both ends are greater than k.
In the third example, Mishka's solving skill is so amazing that he can solve all the problems.
在第一个例子中,Mishka 可以按如下顺序解题:[4,2,3,1,5,1,6,4]→[2,3,1,5,1,6,4]→[2,3,1,5,1,6]→[3,1,5,1,6]→[1,5,1,6]→[5,1,6],因此解出的问题数量为 5。
在第二个例子中,Mishka 无法解出任何问题,因为两端问题的难度均大于 k。
在第三个例子中,Mishka 的解题能力非常出色,以至于他能够解出所有问题。
输入解题思路,AI测评打分。不知道怎么写?