【链接】 我是链接,点我呀:)

【题意】

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;
}

最新文章

  1. 学习AOP之深入一点Spring Aop
  2. button按钮波纹,箭头特效css
  3. erlang文章博客推荐
  4. jQuery插件开发的两种方法及$.fn.extend的详解
  5. 简单两句话解释下prototype和__proto__
  6. 贪心 Codeforces Round #289 (Div. 2, ACM ICPC Rules) B. Painting Pebbles
  7. MySQL下划线特殊字符(Like 语句)
  8. maven寻找jar
  9. 文本分析工具awk简单示例
  10. MATLAB importdata函数返回值类型
  11. hdu3006(状态压缩)
  12. JS开发引用HTML DOM的location和document对象
  13. RHEL6安装python包tornado
  14. maven wrapper使用本地maven
  15. Webform--LinQ 分页组合查询
  16. 制作voc2007数据格式的数据集
  17. ubuntu安装rabbitmq(转)
  18. var foo = function bar() {}
  19. 使用recyclerView item布局match_parent属性失效的问题
  20. es6/es7/es8常用新特性总结(超实用)

热门文章

  1. 读MBA经历回想(下)做法决定结果——北漂18年(49)
  2. Get Started with Git and Team Services
  3. 关于router-link的传参以及参数的传递
  4. spark network-common
  5. offSet和client和scroll
  6. zhizhang错误(每天更新更新)
  7. 解决root登录 -bash-4.2# 的问题
  8. 【习题 8-1 UVA - 1149】Bin Packing
  9. C++异常实现与longjmp, setjmp,栈指针EBP, Active Record
  10. thinkphp内置标签简单讲解