CodeForces - 879B Table Tennis (不要只顾这个数的一边,这个数的前面和后面都的顾)

基于smart_rtmp直播,最简单的部署手册 版本号 添加内容 修改时间 V1.0 新建 2021年12月30日 V1.1 增加网页播放 2021年12月31日 V1.2 增加是否可以多流和测试数据 2022年1月5日 目录 一、软件储备 1.推流软件:OBS 2.服务器流媒体软件:smart_rtmp 3.播放软件:Pot... 阅读详情

n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner.

For each of the participants, you know the power to play table tennis, and for all players these values are different. In a game the player with greater power always wins. Determine who will be the winner.

Input

The first line contains two integers: n and k (2 ≤ n ≤ 500, 2 ≤ k ≤ 1012) — the number of people and the number of wins.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ n) — powers of the player. It's guaranteed that this line contains a valid permutation, i.e. all ai are distinct.

Output

Output a single integer — power of the winner.

Example
Input
2 2
1 2
Output
2 
Input
4 2
3 1 2 4
Output
3 
Input
6 2
6 5 3 1 2 4
Output
6 
Input
2 10000000000
2 1
Output
2
Note

Games in the second sample:

3 plays with 1. 3 wins. 1 goes to the end of the line.

3 plays with 2. 3 wins. He wins twice in a row. He becomes the winner.


题意: 打乒乓球,输入两个数 n,h,共有n 个人,h为要赢的场次数,下面一行为n个人的能量;先让前两个人开始打比赛,赢的人依次和下面的人打比赛,输的人在最后面排队,两个人输赢有两个人的能量定,能量高的人赢,输出第一个赢的h场的人;

思路:这是一道模拟题,数据范围可定义为 long long 首先要思考若轮完一轮了,还没有人赢h场,这时候一定是能量最高的那个人赢;还有在中间的人一定要和他的前一个人比(这一不要忘了)也和他后面的人比赛;记录每一个人第一轮能赢几场就行了,这道题主要就是不要只顾一边,前 后 都要顾,一定不要忘了和他前一个人相比;

代码:

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define Max 550

long long a[Max],hou[Max];
int main()
{
	long long i,j,n,h;
	while(~scanf("%lld%lld",&n,&h))
	{
		long long Ma = -1;
		for(i=0;i<n;i++)
		{
			scanf("%lld",&a[i]);
			Ma = max(Ma,a[i]);
		}	
		for(i=0;i<n;i++)
		{
			long long num ;
			if(i>0&&a[i]>a[i-1])  // 一定不要忘了和他前一个人相比; 
				num = 1;
			else num = 0;
			for(j=i+1;j<n;j++)
			{
				if(a[i]>a[j])
					num++;
				else break;
			}
			if(num>=h)
			{
				printf("%lld\n",a[i]);
				break;
			}
		}
		if(i>=n)
			printf("%lld\n",Ma);
	}
	return 0;
}


【运筹学】什么是基变量?对于线性规划问题中“基”概念的理解(3月3日学习笔记) 在学习《线性规划与目标规划》的过程中,课程的主讲老师郭韧给出了对于基概念的定义如下图 图片来源:运筹学(中国大学mooc网) 由此我产生了几个疑惑:1.如何理解B是线性规划问题的一个基?2.为什么说最多有CnmC_n^mCnm​个基呢?     1.如何理解B是线性规划问题的一个基?1.如何理解B是线性规划问题的一个基?1.如何理解B是线性规划问题的一个基? 在回答第一个... 阅读详情

相关推荐

Spark入门:从零到能跑的实战教程

Spark 的强大在于它统一了大数据处理的多种场景,从批处理到流处理,从 SQL 到机器学习。对于初学者来说,理解 Spark 的核心理念——内存计算和分布式抽象,是最重要的一步。接着,学会用 PySpark 搭建环境,能读数据、能写 SQL,基本上就入门了。剩下的路,就是通过实战去加深理解。写到这里,相信你对 Spark 已经有了一个比较完整的认识。下一步,不妨自己动手写几个 PySpark 脚本,跑一跑日志数据,或者尝试用 Spark SQL 做一个统计。

Morpheon的博客 1367

Table Tennis CodeForces - 879B (思维+模拟)

Table Tennis CodeForces - 879B n people are standing in a line to play table tennis. At first, the first two players in the line play a g...

codeswarrior的博客 750

量子磁场测量技术在生物磁场成像领域的应用现状与产业趋势

首先对量子磁场测量技术的发展进行了简述,然后介绍了量子磁场测量技术在生物磁场成像领域的应用,最后分析了量子磁场测量技术的两大重要应用方向(心磁图仪和脑磁图仪)及其产业现状和未来发展趋势。美国普林斯顿大学在《自然》上公布了目前人类磁场测量灵敏度最高的基于量子磁场测量技术的零场原子磁力计。拥有巨大的发展潜力及庞大的市场空间。因此其数千万元的高昂售价及每年数百万元的超导维护成本限制了超导式心磁图仪的发展和临床应用。而基于超导式脑磁图仪的癫痫、阿尔兹海默症、抑郁症等脑疾病患者的临床研究也取得丰富的研究成果。

罗伯特技术屋 1528

Codeforces 879 B Table Tennis(模拟)

题目链接 题目大意:已知一队网球运动员,排成一队,一开始前两个运动员比赛,输的人到队尾,赢的人继续和队头比赛。 问那个运动员先获得k次胜利,输出该运动员的实力。 题目分析:单纯是数据吓人题,题目说了每个运动员实力都不同,如果k>n的时候队中所有人(最强的除外)在得到k次胜利之前都会遇到最强的人,从而达不到k次胜利。 而当最强的人获胜之后就可以一直赢下去知道他赢了k次。所以当k>n时直接输出

xiuya19的博客 336

华硕ROG玩家国度安装Ubuntu双系统避坑指南:安全启动密钥那些事儿

本文详细解析了在华硕ROG玩家国度设备上安装Ubuntu双系统时,如何正确处理BIOS中的安全启动(Secure Boot)与密钥管理,避免常见的引导失败和Windows系统无法启动问题。指南提供了从数据备份、启动盘制作到BIOS精细设置(如将OS Type改为Other OS而非简单关闭Secure Boot)以及分区规划的完整流程,确保两个系统都能稳定共存。

weixin_29219189的博客 753

±10V ADC 输入电路的高共模差分输入电压

这篇文章分析了±10V ADC输入电路的设计需求与挑战,重点讨论了高共模差分输入电压的处理方案。文章首先明确了设计目标,即安全转换±10V差分信号并保持信号完整性,同时克服高共模电压、阻抗匹配和噪声优化等难点。随后详细比较了仪表放大器和差分放大器的性能特点,并提出了器件选型理论。在信号链架构部分,文章通过公式推导阐述了增益设置、共模抑制设计和输入阻抗匹配等关键技术。此外,还建立了噪声源模型,提出了噪声优化措施。最后,文章总结了设计验证方法,并扩展了在工业保护和生物电信号采集等场景的应用。该设计强调根据具体应

泛红尘的博客 1959

Codeforces 879B (implement)

题目注意两个地方:一个是k的取值范围太大,需要longlong保存,一个是除了第一位的胜场是从0计数,剩下n-1位的胜场都是从1计数。/* * 20171028 */#include <cstdio> #include <algorithm> #include <cmath> #include <cstring> #include <cstdlib>using namespace std;int p

ShellDawn的博客 681

葵花 Himawari 8/9号数据学习记录-01-数据初识

葵花卫星学习记录,第一章:卫星的来源与卫星数据的波段介绍

weixin_44111909的博客 533

ACM刷题之codeforce————Table Tennis

Table Tennistime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputn people are standing in a line to play table tennis. At first, the first two players ...

小时的枫的博客 584

华为eNSP与VMware虚拟机联动实战:从零搭建仿真网络环境

本文详细介绍了如何从零开始搭建华为eNSP与VMware虚拟机的联动仿真网络环境。通过环境准备、网络适配器配置、eNSP与VMware网络集成、安全策略与NAT配置等步骤,帮助读者掌握构建企业级网络实验场景的关键技术。这种组合特别适合网络工程师进阶训练和华为认证考试准备,实现低成本、高灵活性的网络仿真实验。

weixin_30415113的博客 502

解析AI人工智能领域AI芯片的散热技术

当你用ChatGPT写代码、用AI生成高清图片时,背后的AI芯片可能正在“发高烧”——全球TOP500超算的平均功耗已突破10兆瓦,单颗GPU的峰值功耗超过700W(相当于3台家用空调同时运行)。本文将聚焦AI芯片的散热技术,覆盖从基础原理到前沿方案的全链条解析,帮助读者理解“散热为什么比算力更重要”。

AIGC应用创新大全的博客 934

codeforces 443 B.Table Tennis

n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k ga

风的记忆 1261

【原理图PCB专题】Allegro模块化移动器件报...has the LOCKED property怎么解锁?

正常来说做好一个模块化,如果不需要再动,最好还是lock,防止不明白的工程师异动导致问题。如果复用布局设计时,因为有些器件和拓扑并不完全一致,那需要调整部分器件,被锁之后只能全选,无法修改。所以解开锁定后,就能正常编辑了。

一点硬件 2391

CodeForces 879B Table Tennis

CodeForces 879B Table Tennis B. Table Tennis time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output n people are standing in a line to play table te...

weixin_43895356的博客 313

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Codeforces 879B Table Tennis

Table Tennis time limit per test 2 seconds memory limit per test 256 megabytes npeople are standing in a line to play table tennis. At first, the first two players in the line play a game. Then...

暗夜的彩虹的博客 301

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

B. Table Tennis Codeforces 879-B 赛后题解

B. Table Tennis Codeforces 879-B 赛后题解

qq_24481913的博客 240

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

B - Table Tennis CodeForces - 879B

n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from

Fusheng_Yizhao的博客 630

CodeForces - 879B Table Tennis

Table Tennis n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winn...

weixin_30399821的博客 148

Codeforces 879-B. Table Tennis

B. Table Tennis time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output n people are standing in a line to play table tennis. At first, the first

辞树 648

Codeforces Round #443 (Div. 2) B. Table Tennis

Codeforces Round #443 (Div. 2) B. Table Tennis 879B 啊啊啊啊啊啊 做的时候太天真了……一开始的直觉是对的……orz后来想多了,pretest还过了orz没想到啊orz,竟然wa了…… 一开始被k的大小迷惑了……根本就不用管呐,k>n的话,必然是序列中最大值的赢,k<n的话就循环判断谁的逆序数(或者逆序数+1)最先达到k ...

weixin_30354675的博客 71

Codeforces Round #443 (Div.2) - B - Table Tennis

B. Table Tennis time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output n people are standing in a line to play tab

vloai 699

Codeforces Round #443 (Div. 2) 【A、B、C、D】

Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis【水题】 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 in...

dhe56357的博客 148

Codeforces Round #443 B. Table Tennis

题目链接:http://codeforces.com/contest/879/problem/B 题意:n个人比赛,每个人有固定的能力值,能力值较大的人一定赢,比赛次序是依次进行的,1与2 然后1赢了就和3...,要求赢k次的算winner 思路:如果k>=n,那么要能够赢k次,显然只能是能力值为n的值,否则的话就扫一遍,遇到赢k次的人就输出他的能力值(代码是用队伍模拟的 麻烦了 其实

可我只是梦呓,半生半生的无力 165

Table Tennis Codeforces 879B Round #443 Div.2 贪心 模拟

可以证明,当k>=n的时候,必定是队伍里面实力最强的人胜利,因此对于这种情况,我们直接取队伍的最大能力值输出即可。 对于k<n的情况,我们模拟就可以了。 模拟用STL里面的双端队列(deque)是可以的,并且很方便,下面的代码就是用的deque。 当然也可以只用一个queue单向队列,每次贪心地保留最大值,将保留的与新队首进行比较,然后pop掉其中一个也可以。 其他细节可以看代...

weixin_34254823的博客 253
上一篇: CodeForces - 877B Nikita and string (前缀和后缀,任意删除)
下一篇: CodeForces - 877C Slava and tanks (在这个位置的炸一下,这个位置的坦克就跑到相邻的其中一个位置,一个坦克炸两下才能坏 ,求最小的轰炸数)
obsorb_knowledge
博客等级 码龄9年 38粉丝 213原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值