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. C语言I博客作业08

    这个作业属于那个课程 C语言程序设计II 这个作业要求在哪里 作业 我在这个课程的目标是 熟悉使用while和do-while结构解决问题 这个作业在那个具体方面帮助我实现目标 pta题目及查找的资料 ...

  2. 连接xshell 时 连不上的问题

      最近这一周由于自己的xshell突然连接不到虚拟机,在网上找了很多种方法也没能解决,以至于自己在学习很多知识的时候都没能很好的去验证,去尝试.最后在求助大佬的时候终于将xshell重新连接到了虚拟 ...

  3. Android Debug 之 Log 最佳实践

    本文微信公众号「AndroidTraveler」首发. 背景 在开发过程中,调试是必不可少的一项工作. 当我们要确定项目的逻辑时,当我们要了解界面的生命周期时,当我们发现新写的逻辑与期望效果不一致时, ...

  4. [springboot 开发单体web shop] 6. 商品分类和轮播广告展示

    商品分类&轮播广告 因最近又被困在了OSGI技术POC,更新进度有点慢,希望大家不要怪罪哦. 上节 我们实现了登录之后前端的展示,如: 接着,我们来实现左侧分类栏目的功能. ## 商品分类|P ...

  5. PHP中高级面试题 一个高频面试题:怎么保证缓存与数据库的双写一致性?

    分布式缓存是现在很多分布式应用中必不可少的组件,但是用到了分布式缓存,就可能会涉及到缓存与数据库双存储双写,你只要是双写,就一定会有数据一致性的问题,那么你如何解决一致性问题? Cache Aside ...

  6. mysql 不需要使用密码就可以登录

    最近发现一个问题, 就是我等了mysql客户端可以不输入密码. 直接输入mysql -u root 回车 或者 输入一个错的密码,都可进入到下面的界面. 在Navicat不用输入密码, 或者数据错的密 ...

  7. SQL SERVER中SELECT和SET赋值相同点与不同点

    SELECT和SET在SQL SERVER中都可以用来对变量进行赋值,但其用法和效果在一些细节上有些不同. 1. 在对变量赋值方面,SET是ANSI标准的赋值方式,SELECT则不是.这也是SET方式 ...

  8. 基于 HTML5 + WebGL 的宇宙 3D 展示系统

    前言 近年来随着引力波的发现.黑洞照片的拍摄.火星上存在水的证据发现等科学上的突破,以及文学影视作品中诸如<三体>.<流浪地球>.<星际穿越>等的传播普及,宇宙空间 ...

  9. Selenium+Java(十一)Selenium窗口切换

    前言: Selenium在当前页面调整到新页面时打开了新的窗口,此时就需要跳转到新的窗口去,需要把窗口进行切换. 获取窗口句柄方法: 获取所有: //获取所有窗口句柄,返回的是set类型 driver ...

  10. P2669 金币

    题目描述 国王将金币作为工资,发放给忠诚的骑士.第一天,骑士收到一枚金币:之后两天(第二天和第三天),每天收到两枚金币:之后三天(第四.五.六天),每天收到三枚金币:之后四天(第七.八.九.十天),每 ...