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

【OpenClaw从入门到精通】第03篇:吃透Gateway/Skills/ClawHub核心概念(2026实测+避坑) 本文针对OpenClaw新手易混淆的核心概念痛点,以通俗类比+实操演示拆解OpenClaw核心、Gateway、Skills、ClawHub四大组件。通过“数字员工团队”类比明确各组件定位:OpenClaw核心是“老板”(调度中心)、Gateway是“前台+后勤”(后台进程)、Skills是“专业员工”(功能插件)、ClawHub是“人才市场”(技能商店)。补充版本更名史、技能加载优先级、ClawHub与GitHub区别等关键细节,结合“AI融资新闻查询并邮件推送”虚拟案例演示组件协同流程,梳理5个高频认知 阅读详情

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

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

这道题就是每次把第一个人和他后面的人比较,同时计数,如果过程中计数结果比K大,就直接输出当前值,如果比较有大于的数,就更换答案,计数变成1,重新计数,如果始终没有出现,就输出数列中最大的数。

code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
int main(){
    int n;
    int a[600],st;
    ll k;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = a[0];
    st = 0;
    for(int i = 1; i < n; i++){
        if(st >= k){
            cout << ans << endl;
            return 0;
        }
        if(ans > a[i])
            st++;
        else{
            st = 1;
            ans = a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

2024年数字IC秋招-大疆-数字芯片开发工程师-笔试题 笔试题型:选择题 + 简答题笔试平台:大疆创新(电脑监控)笔试时间:90min做题感受:知识面覆盖很广,很多题目不会做(1) 什么是功耗优化中的DVFS技术?(2)降低功耗的原理是什么?(3)一般工作流程是怎样的?(4)必须的硬件模块有哪些? 阅读详情

相关推荐

基于STM32的半导体制冷片温度控制

制冷片温度控制,温控范围15℃~45℃,本人菜鸡一枚,大佬绕路。 #include "stm32f10x_gpio.h" #include "relay.h" void relay_Init(void){ GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);//Ê...

大白兔的博客 9014

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

OSMDroid(1)——OSM简介,基础例子搭建

1.OSMDroid简介 Osmdroid是一款完全开源的地图基本操作SDK,相比于现在普遍使用的百度地图,高德地图,谷歌地图等最大的好处就是开源。 最近在做一个军方项目,要求完全不能联网,从开发到应用整个阶段都是在局域网进行,相比之下采用了OSMDroid这个SDK作为解决方案。 先来看OSMDroid,便是(OpenStreetMapForAndroid),后面都简称OSM...

robotskly的博客 6177

Codeforces 879 B Table Tennis(模拟)

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

xiuya19的博客 336

零代码搭建专业知识库:Wiki.js+cpolar让团队协作像写笔记一样简单

"项目文档又找不到了!“团队负责人小张第N次在群里看到这样的抱怨——技术文档分散在邮件、网盘和个人电脑里,新人入职要花一周熟悉文档位置,远程协作时版本混乱更是家常便饭。Wiki.js与cpolar内网穿透服务的出现,就像给团队协作装上了"中央大脑”,用写Markdown笔记的简单方式,搭建一个专业的知识库系统。普通人对知识管理的需求其实很简单:方便记录、容易查找、大家能用。但传统方案把这个过程搞得异常复杂:建服务器、配环境、学语法、搞权限……大部分团队还没开始就放弃了。

Yawesh的博客 2036

数据预处理的分箱操作

数据分箱 介绍 我们在建立模型前,一般需要对特征变量进行离散化,特征离散化后,模型会更稳定,降低模型过拟合的风险。尤其是采用 logsitic 建立评分卡模型时,必须对连续变量进行离散化。而特征离散化处理通常采用的就是分箱法,数据分箱(也称为离散分箱或分段)是一种数据预处理技术,用于减少次要观察误差的影响,提高泛化性。 数据分箱又分为有监督分箱和无监督分箱,是否使用标签进行离散化(分箱)决定了有监督还是无监督的离散化方法。 知识点 无监督分箱 split 分箱 merge 分箱 无监督分箱 这里为了

随笔记 5332

(转)学习c/c++的50个好网站

豆瓣猜 发现小站 线上活动 (转)学习c/c++的50个好网站 2010-04-01 10:12:43 来自: 你不躲猫猫(why我所做的看起来像一个笑话) 1、http://snippets.dzone.com/tag/c/ --数以千计的有用的C语言源代码片段 2、http://www.hotscripts.com/categor

Crazy Ak-47 7268

2025资源从哪里来!

研究网络通信中的安全问题,如VLAN划分、路由协议(静态、动态如OSPF、BGP)、NAT转换、AAA认证、访问控制列表(ACL)等。‌Wi-Fi安全设置‌、‌密码破解原理‌(仅用于合法测试或教育目的)、‌常见Web安全问题‌如SQL注入、XSS跨站脚本攻击等的防范措施。在这个网站你可以找到你对应的专业-对应的路线-对应的资源-对应的百度网盘里面全是免费的资源------------------惊喜不?‌防火墙配置与策略‌、‌入侵检测与防御系统(IDS/IPS)‌、‌端口扫描与漏洞扫描技术‌等。

qq_56248592的博客 1902

爱情来的太快就像龙卷风

题解 uuuu yyy uuu uuu ooo rrr rr w iii ee ww yyy ooo eee uuu rrr ee yy e 首先再26个键盘上找到u所对应一行u是第几个字母u对应第7个所以对应九宫格第7个格u有四个所以是第七个格里第四个字母s,以此类推

qq_45717538的博客 8万+

【Burp入门第三十一篇】Burp+SwitchyOmega实现本地localhost代理

在部分情况下(如本地靶场),当我们需要在Burp中查看、修改本地流量包的时候,按以下三个配置是不能得到本地流量包的。

等风来 3214

【本地部署实战】LM Studio深度使用指南:从环境搭建到模型调优

LM Studio通过极简的操作流程和强大的生态兼容性,让本地部署大模型成为可能。随着M4芯片的发布和CUDA 12.0的优化,未来本地化AI开发将迎来新的爆发点。建议开发者关注官方Discord社区(https://discord.gg/lmstudio)获取最新模型支持信息。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 8749

在Bluemix 使用OpenWhisk & Node-red 開發Event-Driven 應用系

2016/2/22 IBM Bluemix 已宣布推出开源的 OpenWhisk,有了OpenWhisk,开发者对于前端的触发 (trigger) 事件,后端不需安装 Server,只要开发一小段的JavaScript程序代码片段、Swift程序代码,或是嵌在Docker container里面的二进制程序(统称为 Action )来响应这些不同的触发事件。

chenjaulin的博客 4万+

【深度学习新浪潮】Harness Engineering 入门实战必看|6个从零可跑开源项目,新手快速上手垂域AI工程落地

很多同学入门 AI Agent、做大模型垂域落地时,都会卡在同一个痛点:只会调用模型、写简单Prompt,却不懂如何做约束管控、流程护栏、任务编排、多智能体边界隔离。而这正是的核心价值。不同于纯理论概念,Harness Engineering 更偏向工程实战,新手不用啃复杂论文,从开源项目动手实操是最高效的学习方式。本文从零基础易上手、可本地一键部署、支持二次改造做实战项目。

专注:太空算力、AI infra、异构调度、大模型成本工程 231

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

android 蓝牙通讯demo

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

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

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

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

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 winner plays with the

>*,< 303

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

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

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

qq_24481913的博客 240

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

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

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

weixin_34254823的博客 253

CodeForces - 879B 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 fro

obsorb_knowledge的博客 768

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 B. Table Tennis

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

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

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
上一篇: Teams Formation CodeForces - 878B (思维+模拟)
下一篇: Balanced Substring CodeForces - 873B (思维+前缀和)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值