Mishka started participating in a programming contest. There are nn problems in the contest. Mishka's problem-solving skill is equal to kk.

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 kk. When Mishka solves the problem, it disappears from the list, so the length of the list decreases by 11. Mishka stops when he is unable to solve any problem from any end of the list.

How many problems can Mishka solve?

Input

The first line of input contains two integers nn and kk (1≤n,k≤1001≤n,k≤100) — the number of problems in the contest and Mishka's problem-solving skill.

The second line of input contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1001≤ai≤100), where aiaiis the difficulty of the ii-th problem. The problems are given in order from the leftmost to the rightmost in the list.

Output

Print one integer — the maximum number of problems Mishka can solve.

Examples

Input
8 4
4 2 3 1 5 1 6 4
Output
5
Input
5 2
3 1 2 1 3
Output
0
Input
5 100
12 34 55 43 21
Output
5

Note

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][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 55.

In the second example, Mishka can't solve any problem because the difficulties of problems from both ends are greater than kk.

In the third example, Mishka's solving skill is so amazing that he can solve all the problems.

题目意思:一个人有n个问题需要去解决,他的解题能力为kk,只能解决难度比kk小的题目,解题的过程是从左边或者从右边开始解题,当他遇到解不出来的题的时候就会停止解题。

解题思路:使用一个双指针,一个从头到尾,一个从尾到头,分别遍历,记录比kk小的数的个数即可。

 #include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n,m,flag,count;
int a[],i;
scanf("%d%d",&n,&m);
for(i=;i<n;i++)
{
scanf("%d",&a[i]);
}
flag=;
count=;
for(i=;i<n;i++)
{
if(a[i]<=m)
{
count++;
}
else
{
break;
}
}
if(i>=n)
{
flag=;
}
if(!flag)
{
for(i=n-;i>=;i--)
{
if(a[i]<=m)
{
count++;
}
else
{
break;
}
}
}
printf("%d\n",count);
return ;
}

Mishka and Contest(模拟水题)的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. POJ 2014:Flow Layout 模拟水题

    Flow Layout Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3091   Accepted: 2148 Descr ...

  3. 模拟水题,查看二维数组是否有一列都为1(POJ2864)

    题目链接:http://poj.org/problem?id=2864 题意:参照题目 哈哈哈,这个题discuss有翻译哦.水到我不想交了. #include <cstdio> #inc ...

  4. CodeForces 689A Mike and Cellphone (模拟+水题)

    Mike and Cellphone 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/E Description While sw ...

  5. UVA 10714 Ants 蚂蚁 贪心+模拟 水题

    题意:蚂蚁在木棍上爬,速度1cm/s,给出木棍长度和每只蚂蚁的位置,问蚂蚁全部下木棍的最长时间和最短时间. 模拟一下,发现其实灰常水的贪心... 不能直接求最大和最小的= =.只要求出每只蚂蚁都走长路 ...

  6. B. Creating the Contest(水题)

    直接水过 #include<iostream> #include<algorithm> using namespace std; ; int a[maxn]; int n, u ...

  7. Codeforces 1082B Vova and Trophies 模拟,水题,坑 B

    Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...

  8. HDU4287-STL模拟水题

    一场2012天津网络预选赛的题,签到题. 但是还是写了三四十分钟,C++和STL太不熟悉了,总是编译错误不知道怎么解决. 一开始用的Char [] 后来改成了string,STL和string搭配起来 ...

  9. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

随机推荐

  1. FreeImage 生成带透明通道的GIF

    主要方法: 加载图像及读取参数 FreeImage_Load FreeImage_GetWidth FreeImage_GetHeight FreeImage_Allocate FreeImage_G ...

  2. Linux-帮助的用法

    Linux帮助使用方法 内部命令:help COMMAND 或 man bash外部命令: (1) COMMAND --help   COMMAND -h --help和-h选项显示用法总结和参数列表 ...

  3. 高级同步器:可重用的同步屏障Phaser

    引自:https://shift-alt-ctrl.iteye.com/blog/2302923 在JAVA 1.7引入了一个新的并发API:Phaser,一个可重用的同步barrier.在此前,JA ...

  4. Python模块、包、异常、文件(案例)

    Python模块.包.异常.文件(案例) python.py #模块 # Python中的模块(Module),是一个Python文件,以.py文件结尾,包含了Python对象定义和Python语句, ...

  5. SSM+poi导入和导出

    最原始数据 导入成功后 下载数据 下载后的数据显示 数据变成16条 点击导出可选择 导了两次  看数据变化 数据库字段在下面地址给出 首先贴出Dao层 List<User> findAll ...

  6. python3.X 安装web.py 失败的解决方法

    python2.x 安装python是非常顺利的 但是 在进行 pip3 install web.py 时提示很多错误 例如缺少模块 语法错误...... 最后试了一下web.py 的dev版本 pi ...

  7. 【MYSQL笔记】

    1.去重取出id最小的记录 tip:在laravel框架里配置信息database设置了'strict' => true,所以在groupBy时只能select出groupBy后的字段,当想搜索 ...

  8. HaoheDI让ETL变得简单

    HaoheDI(昊合数据整合平台)http://www.haohedi.com,产品基于BS架构,开发运维均极为简单,可快速搭建ETL平台,广泛支持各种数据库.文本文件.SAP和Hadoop,开发数据 ...

  9. python学习——常用模块

    在学习常用模块时我们应该知道模块和包是什么,关于模块和包会单独写一篇随笔,下面先来了解有关在python中的几个常用模块. 一.什么是模块 常见的场景:一个模块就是一个包含了python定义和声明的文 ...

  10. 对Python语法简洁的贴切描述

    很多人认为,Python与其他语言相比,具有语法简洁的特点.但这种简洁到底体现在哪些地方,很少有人能说清楚.今天看到一个对这一问题的描述,个人觉得很不错,原文如下: “Python语法主要用来精确表达 ...