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 aiai is 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
Copy
8 4
4 2 3 1 5 1 6 4
output
Copy
5
input
Copy
5 2
3 1 2 1 3
output
Copy
0
input
Copy
5 100
12 34 55 43 21
output
Copy
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.

AC代码:

#include<bits/stdc++.h>
using namespace std;

int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n,k,a[110],flag1,flag2,cnt=0;
cin>>n>>k;
flag1=1,flag2=n;
for(int i=1;i<=n;i++) cin>>a[i];

while(flag1<=flag2)
{
while(a[flag1]<=k && flag1<=flag2)
{
cnt++;
flag1++;
}
while(a[flag2]<=k && flag1<=flag2)
{
cnt++;
flag2--;
}
if(a[flag1]>k&&a[flag2]>k) break;
}

cout<<cnt<<endl;

return 0;
}

CodeForces-999A-Mishka and Contest的更多相关文章

  1. codeforces 703E Mishka and Divisors

    codeforces 703E Mishka and Divisors 题面 给出大小为\(1000\)的数组和一个数\(k\),求长度最短的一个子序列使得子序列的元素之积是\(k\)的倍数,如果有多 ...

  2. Codeforces 703D Mishka and Interesting sum 离线+树状数组

    链接 Codeforces 703D Mishka and Interesting sum 题意 求区间内数字出现次数为偶数的数的异或和 思路 区间内直接异或的话得到的是出现次数为奇数的异或和,要得到 ...

  3. Codeforces 703B. Mishka and trip 模拟

    B. Mishka and trip time limit per test:1 second memory limit per test:256 megabytes input:standard i ...

  4. Codeforces 703D Mishka and Interesting sum(树状数组+扫描线)

    [题目链接] http://codeforces.com/contest/703/problem/D [题目大意] 给出一个数列以及m个询问,每个询问要求求出[L,R]区间内出现次数为偶数的数的异或和 ...

  5. CodeForces 377B---Preparing for the Contest(二分+贪心)

    C - Preparing for the Contest Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d ...

  6. Mishka and Contest(模拟水题)

    Mishka started participating in a programming contest. There are nn problems in the contest. Mishka' ...

  7. CodeForces B. Creating the Contest

    http://codeforces.com/contest/1029/problem/B You are given a problemset consisting of nn problems. T ...

  8. codeforces B. Valera and Contest 解题报告

    题目链接:http://codeforces.com/problemset/problem/369/B 题目意思:给出6个整数, n, k, l, r, sall, sk ,需要找出一个满足下列条件的 ...

  9. CodeForces 703A Mishka and Game

    简单题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #inclu ...

  10. Codeforces 140D - New Year Contest

    140D - New Year Contest 思路:贪心+排序.罚时与时间成正比,因为在0点前做完的题都可以在0点提交.从时间短的开始做最优. 代码: #include<bits/stdc++ ...

随机推荐

  1. django 之创建自己的模板(使用案例)

    Django 创建自己的模板篇(实例) 此处需要创建模板,主要是对自己的模板进行扩展: 一般是扩展模板的tag和filter两个功能.可以用来创建你自己的tag和filter功能库. 创建模板库 分为 ...

  2. echo -e的扩展应用之颜色控制输出(字体+背景)

    echo -e 输出带颜色字体或者背景用法:example: echo -e "\033[41;36m something here \033[0m" 其中41的位置代表底色, 3 ...

  3. jquery ajax在 IE8/IE9 中无效

    你们是不是也曾经和我以为遇到过这样的情况呢,jquery ajax在 IE8/IE9 中无效获取不到数据呢,经过熬夜找到好的东西和你们分享一下就是jQuery-ajaxTransport-XDomai ...

  4. Docker从入门到实践(1)

    一.Docker简介 1.1.什么是 Docker Docker 最初是 dotCloud 公司创始人 Solomon Hykes 在法国期间发起的一个公司内部项目,它是基于 dotCloud 公司多 ...

  5. mysql清空数据库下所有的表

    一.使用以下命名获取truancate  数据库 lz_garden 下所有表,并将其导入到 d盘 为 out.sql select Concat('TRUNCATE TABLE ', TABLE_N ...

  6. windows版本 MongoDB副本集搭建及开启身份验证

    ------------恢复内容开始------------ ------------恢复内容开始------------ MongoDB副本集搭建 我搭建的是一个主节点,两个副节点 构建目录结构如下 ...

  7. 更改input标签的placeholder的样式

    主要是要区别不同浏览器的不同css类 在input框中有时想将输入的字和placeholder设为不同的颜色或其它效果,这时就可以用以下代码来对placeholder进行样式设置了. input::- ...

  8. Codecommit

    1. 生成IAM 用户组并附权限. 2.生成IAM用户并加入组. 3. 为用户生成key-pair 4. 上传公钥到aws 5. 配置config文件,其中user是aws 为公钥生成的id. 6. ...

  9. [FPGA]浅谈LCD1602字符型液晶显示器(Verilog)

    目录 概述 LCD1602 LCD1602是什么? LCD1602的管脚 RS_数据/命令选择 E_使能 D0-D7 LCD1602有个DDRAM LCD1602还有个CGROM 指令集 清屏 进入模 ...

  10. D^3ctf两道 pwn

    这次 的D^3ctf 又是给吊打 难顶... 所以题都是赛后解出来的,在这感谢Peanuts师傅 unprintableV 看看保护: 看看伪代码,其实代码很少 void __cdecl menu() ...