acm第二天(代码片段)

weixq351 weixq351     2022-12-16     697

关键词:

A - Mishka and Contest

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?

Input

The first line of input contains two integers n

and k (1n,k100

) — the number of problems in the contest and Mishka‘s problem-solving skill.

The second line of input contains n

integers a1,a2,,an (1ai100), 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.

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]

, 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.

 1 #include<stdio.h>
 2 int main()
 3 
 4     int n,k;
 5     int a[102];
 6     int s=0;
 7     int t=0;
 8     scanf("%d %d",&n,&k);
 9     for(int i=0;i<n;i++)
10     
11         scanf("%d",&a[i]);
12     
13     for(int i=0;i<n;i++)
14     
15 
16         if(a[i]<=k)
17         
18             s++;
19             t++;
20         
21         else
22             break;
23     
24     for(int i=n-1;i>=t;i--)
25     
26         if(a[i]<=k)
27         
28             s++;
29         
30         else
31             break;
32     
33     printf("%d
",s);
34     return 0;
35 

 

flink获取第二天的0点时间(代码片段)

获取格林威治标准时间的第二天00:00:00即获取北京时间的第二天08:00:00valts=(ctx.timerService().currentProcessingTime()/(1000*60*60*24)+1)*(1000*60*60*24)获取北京时间的第二天00:00:00valts=(ctx.timerService().currentProcessingTi 查看详情

第二天java基础(代码片段)

第二天JAVA基础变量在程序运行中值可以变化的量;类型变量名;变量的作用域packagecom.zhang.Base;//Demo05类名publicclassDemo05/**变量按照作用域来分有三种:*类变量实例变量局部变量**///类变量staticstaticdoublesalary=3000;//整个类中可使用s... 查看详情

第二天(代码片段)

一、分页功能1、业务逻辑流程? 用户通过点击按钮触发按钮事件,然后将需要展示的页的页码传递给服务器java程序,Controller通过分析URL调用findByPage方法,findByPage通过调用userService中相应的方法将参数传入Service层,userService通过... 查看详情

团队冲刺第二天(代码片段)

昨天完成了主页面的设计今天至少完成一俩个功能按钮里面的界面。进制转化:Stringstr=newBigInteger("number",i).toString(j);System.out.println(str);i进制的number转化成j进制行列式:java中的高效矩阵运算包Ejml的使用 查看详情

基础学习之第二天(代码片段)

 一.格式化输出              现在有以下需求,让用户输入name,age,job,hobby然后输出如下所示:------------infoofAlexLi-----------Name:AlexLiAge22job:TeacherH 查看详情

第二天,ansible源码学习(代码片段)

按照我的理解,源码学习肯定是一边看代码,一边执行程序验证。执行的命令是:ansiblesz003-a"ls-l"下面是ansible.py源码,学习分析以注释的形式出现########################################################from__future__import(absolute_import,divis... 查看详情

初识python第二天(代码片段)

一.传递参数2.1新建Python文件,名为hello_args.py,输入以下代码1importsys2print(sys.argv)通过pythonhello_args.py,屏幕打印输出[‘hello_args.py‘]pythonhello_args.pyhelloworld屏幕打印输出[‘hello_args.py‘,‘hello‘,‘world‘]默认文件名本身是argv[0],属... 查看详情

第二天(代码片段)

2020-03-30还行吧,今天也是一样弄那些包,开心的还是有一个girl聊天勒在准备下班的时候,我和老板老板娘聊天了,他们都不是很喜欢这个girl,可能是年纪小,可能是不太懂做人,当然今天的开心呢也是他们有一丢丢看中我,不过谈到公众... 查看详情

复习第十二天(代码片段)

1.如何实现向下转型?需要注意什么问题?如何解决此问题?Personp=newMan();使用强转符:()Manm=(Man)p;可能ClassCastException异常。使用instanceof在进行向下转型前判断。if(pinstanceofMan)Manm=(Man)p;2.==和equa 查看详情

开始学习python的第二天(代码片段)

一、练习题1.使用while循环输入1234568910#第一种方法count=0whilecount<10:count+=1#count=count+1ifcount==7:print(‘‘)else:print(count)#第二种count=0whilecount<10:count+=1#count=count+1ifcount==7:continueprint(count)2. 查看详情

springboot学习:第二天(代码片段)

三、日志1、日志框架小张;开发一个大型系统;  1、System.out.println("");前期将关键数据打印在控制台;去掉?写在一个文件?  2、后来框架来记录系统的一些运行时信息;日志框架;zhanglogging.jar;  3、再后来加高大上... 查看详情

初识python第二天(代码片段)

在Python中,一切事物都是对象,对象是基于类创建的,对象继承了类的属性,方法等。一.传递参数1.1新建python文件,名为twoday_args.py,输出以下代码1importsys2print(sys.argv)34#传入sys模块ViewCode通过pythontwoday_args.py,屏幕打印输出[‘tw... 查看详情

r语言第二天(代码片段)

查看和更改R语言工作空间getwd()显示当前工作空间setwd()更改当前工作空间 列出当前工作空间的对象ls()rm()移除(删除)一个或多个对象>ls()[1]"b""c""course""d""dat1""depart""dim1"[8]"dim2""dim3""en""grade""i""id""math"[15]"mylist""name""sc""Score""s... 查看详情

认识css的第二天(代码片段)

ul去除自带的样式     <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Title</title><style>ullist-style-type:none;padding-left:0;</style></he 查看详情

莫烦theano学习自修第二天激励函数(代码片段)

1.代码如下:#!/usr/bin/envpython#!_*_coding:UTF-8_*_importnumpyasnpimporttheano.tensorasTimporttheanox=T.dmatrix(‘x‘)#定义一个激励函数s=1/(1+T.exp(-x))logistic=theano.function([x],s)printlogistic([[0,1],[-2,-3]])# 查看详情

python学习第二天(下)(代码片段)

继续上次的笔记 ####判断一个元素是否在列表中9innameprint(9inname)会返回一个True或False的结果 if9inname:#判断一个元素是否在列表中print("9isinname")####判断一个元素出现的次数count()方法 name=["Alex","Jack","Rain",9,4,3,5,634,34,89,"Eri... 查看详情

暑假第二天之每天一些题系列(代码片段)

暑假第二天之每天一些题系列文章目录暑假第二天之每天一些题系列一、选择题二、填空题三、算法题一、选择题表达式0x13&0x17,0x13|0x17的值分别是多少A.0x170x13B.0x130x17C.0xF80xE8D.0xec0xC8答案解析:0x13的二进制为:000100110x... 查看详情

python学习第二天(上)(代码片段)

##课前思想###GENTLEMENCODE1* 着装得体* 每天洗澡* 适当用香水* 女士优先* 不随地吐痰、不乱扔垃圾、不在人群众抽烟* 不大声喧哗* 不插队、碰到别人要说抱歉* 不在地铁上吃东西* 尊重别人的职业... 查看详情