A. Mishka and Contest
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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;
}

CodeForces999A-Mishka and Contest的更多相关文章

  1. Mishka and Contest(模拟水题)

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

  2. CF A.Mishka and Contest【双指针/模拟】

    [链接]:CF/4892 [题意]: 一个人解决n个问题,这个问题的值比k小, 每次只能解决最左边的或者最右边的问题 解决了就消失了.问这个人能解决多少个问题. [代码]: #include<b ...

  3. CF999A Mishka and Contest 题解

    Content 能力值为 \(k\) 的小 M 参加一次考试,考试一共有 \(n\) 道题目,每道题目的难度为 \(a_i\).小 M 会选择两头中的一道难度不超过他的能力值题目去做,每做完一道,这道 ...

  4. ACM 第二天

    A - Mishka and Contest Mishka started participating in a programming contest. There are n problems i ...

  5. [Codeforces]Codeforces Round #490 (Div. 3)

    Mishka and Contest #pragma comment(linker, "/STACK:102400000,102400000") #ifndef ONLINE_JU ...

  6. Codeforces Round #365 (Div. 2) D. Mishka and Interesting sum 离线+线段树

    题目链接: http://codeforces.com/contest/703/problem/D D. Mishka and Interesting sum time limit per test ...

  7. Codeforces 703B. Mishka and trip 模拟

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

  8. CodeForces-999A-Mishka and Contest

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

  9. Programming Contest Problem Types

        Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...

随机推荐

  1. Linux中SSH服务基于key认证实践

    众所周知ssh是目前较可靠,专为远程登录会话和其他网络服务提供安全性的协议,它默认工作在tcp的22号端口,具体实现的软件有:openssh(centos默认安装的),dropbear.ssh协议目前 ...

  2. Linux命令实战(二)

    1.printf格式化输出(format and print data) 语法:printf(选项)(参数) 参数 输出格式:指定数据输出时的格式: 输出字符串:指定要输出的数据. 格式替代符 %c ...

  3. 字体图标转base64

    如果你在阿里矢量库下载了字体图标在项目引入无法显示时,可以把图标转成base64 在线转换的链接 https://transfonter.org/ css字体图标的制作

  4. 心里有点B树

    在说B树之前最好先看看2-3树, 2-3树是B树的一种特例, 什么B树, B树就是2-3树, 2-3-4 树 , 2-3-4-5... 树的统称, 而B+树又是B树的一种变形 性质: 什么是二节点, ...

  5. nyoj 264-国王的魔镜 (string[-1:-int(str_len/2+1):-1])

    264-国王的魔镜 内存限制:64MB 时间限制:3000ms 特判: No 通过数:13 提交数:25 难度:1 题目描述: 国王有一个魔镜,可以把任何接触镜面的东西变成原来的两倍——只是,因为是镜 ...

  6. vuejs学习之项目结构解读

    转载:https://www.cnblogs.com/chenleideblog/p/10484554.html 关于Vue中main.js.APP.vue和index.html之间关系 在初始化vu ...

  7. (三十五)golang--面向对象之多态

    多态:变量具有多种形态,可以用统一的接口来调用不同的实现. 接口体现多态特征: (1)多态参数:之前所讲的Usb接口案例,既可以接受手机变量,也可以接受相机变量,就体现了usb接口的多态: (2)多台 ...

  8. 1 数据 & 图表

    瞎逼逼:虽然是统计专业,但学艺不精.大学受过的专业训练很少,妥妥学渣.因此工作后决定重新复习,阅读材料为贾俊平的<统计学>第7版.每周更新. 我不按照书里的逻辑顺序和所有知识点来写我的笔记 ...

  9. 理解Redis单线程运行模式

    本文首发于:https://mp.weixin.qq.com/s/je4nqCIq6ARhSV2V5Ymmtg 微信公众号:后端技术指南针 0.概述 通过本文将了解到以下内容: Redis服务器采用单 ...

  10. Java Import的使用

    这里根据上一篇中ClassObject.java的例子改编的:https://www.cnblogs.com/jizizh/p/11938574.html 一.创建ClassObjectImport. ...