【Codeforces Round #443 (Div. 2) B】Table Tennis
2024-08-31 17:19:44
【链接】 我是链接,点我呀:)
【题意】
n个人站在一排。
每次第一个人和第二个人打架。
输的人跑到队列的尾巴去。
然后赢的人继续在队首.和第三个人打。
谁会先赢K次。
【题解】
会发现,一轮之后就一直是那个最大的赢了。
则第一轮先模拟,有人达到k次就直接输出它。
否则输出那个最大的就好。
【代码】
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 500;
ll k;
int n;
int a[N+10];
int win[N+10];
int main(){
// freopen("rush.txt","r",stdin);
scanf("%d%lld",&n,&k);
for (int i = 1;i <= n;i++)
scanf("%d",&a[i]);
int now = a[1];
for (int i = 2;i <= n;i++){
if (a[i] < now){
win[now]++;
if (win[now]==k){
printf("%d\n",now);
return 0;
}
}else{
now = a[i];
win[now]++;
if (win[now]==k){
printf("%d\n",now);
return 0;
}
}
}
printf("%d\n",now);
return 0;
}
最新文章
- 学习AOP之深入一点Spring Aop
- button按钮波纹,箭头特效css
- erlang文章博客推荐
- jQuery插件开发的两种方法及$.fn.extend的详解
- 简单两句话解释下prototype和__proto__
- 贪心 Codeforces Round #289 (Div. 2, ACM ICPC Rules) B. Painting Pebbles
- MySQL下划线特殊字符(Like 语句)
- maven寻找jar
- 文本分析工具awk简单示例
- MATLAB importdata函数返回值类型
- hdu3006(状态压缩)
- JS开发引用HTML DOM的location和document对象
- RHEL6安装python包tornado
- maven wrapper使用本地maven
- Webform--LinQ 分页组合查询
- 制作voc2007数据格式的数据集
- ubuntu安装rabbitmq(转)
- var foo = function bar() {}
- 使用recyclerView item布局match_parent属性失效的问题
- es6/es7/es8常用新特性总结(超实用)
热门文章
- 读MBA经历回想(下)做法决定结果——北漂18年(49)
- Get Started with Git and Team Services
- 关于router-link的传参以及参数的传递
- spark network-common
- offSet和client和scroll
- zhizhang错误(每天更新更新)
- 解决root登录 -bash-4.2# 的问题
- 【习题 8-1 UVA - 1149】Bin Packing
- C++异常实现与longjmp, setjmp,栈指针EBP, Active Record
- thinkphp内置标签简单讲解