304617: CF879B. Table Tennis

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Table Tennis

题意翻译

**CF879B Table Tennis ** **题目:** $n$ 个人打乒乓球,先让前两个人打比赛,赢的人依次和下一个人打比赛,输的人到队尾排队.两个人的比赛由这两个人的能力值确定,能力值大的人获胜,所有人的能力值都不同.连续获胜$k$ 场的人将成为胜利者. **输入:** 第一行两个整数 $n$ , $k$ $(2<=n<=500, 2<=k<=10^{12})$ , 分别表示人数和需要连续获胜的次数. 第二行$n$ 个整数 $a_1, a_2,..., a_n (1<=a_i<=n)$ 分别表示每个人的能力值. **输出:** 仅一个整数,胜利者的能力值. By @凌幽

题目描述

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

输入输出格式

输入格式


The first line contains two integers: $ n $ and $ k $ ( $ 2<=n<=500 $ , $ 2<=k<=10^{12} $ ) — the number of people and the number of wins. The second line contains $ n $ integers $ a_{1},a_{2},...,a_{n} $ ( $ 1<=a_{i}<=n $ ) — powers of the player. It's guaranteed that this line contains a valid permutation, i.e. all $ a_{i} $ are distinct.

输出格式


Output a single integer — power of the winner.

输入输出样例

输入样例 #1

2 2
1 2

输出样例 #1

2 

输入样例 #2

4 2
3 1 2 4

输出样例 #2

3 

输入样例 #3

6 2
6 5 3 1 2 4

输出样例 #3

6 

输入样例 #4

2 10000000000
2 1

输出样例 #4

2

说明

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.

Input

题意翻译

**CF879B Table Tennis ** **题目:** $n$ 个人打乒乓球,先让前两个人打比赛,赢的人依次和下一个人打比赛,输的人到队尾排队.两个人的比赛由这两个人的能力值确定,能力值大的人获胜,所有人的能力值都不同.连续获胜$k$ 场的人将成为胜利者. **输入:** 第一行两个整数 $n$ , $k$ $(2<=n<=500, 2<=k<=10^{12})$ , 分别表示人数和需要连续获胜的次数. 第二行$n$ 个整数 $a_1, a_2,..., a_n (1<=a_i<=n)$ 分别表示每个人的能力值. **输出:** 仅一个整数,胜利者的能力值. By @凌幽

加入题单

算法标签: