Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) A = list(map(int, input().split())) Q = max(A) cnt = 0 power = A[0] if A[0] == Q: print(Q) exit(0) for i in range(1, n): if cnt == k: print(power) exit(0) if A[i] == Q: print(Q) exit(0) elif A[i] < power: cnt += 1 else: ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
# @Date: 26-Oct-2017 # @Last modified time: 26-Oct-2017 # after index of max whatever be the power max will win n,k=map(int,input().split()) a=list(map(int,input().split())) maxi=-1 index=-1 # get the maxi index and value for i in range(n): if a[i]>maxi: maxi=a[i] index=i import sys # before i do ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; template <typename P, typename Q> ostream& operator<<(ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; } int main(int argc, char* argv[]) { ios_base::sync_with_stdio(0); cin.tie(0); int n; long long int k; while (cin >> n...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; import java.io.*; import java.lang.Math.*; public class MainA { static int mod = (int) 1e9 + 7; public static void main(String[] args) throws java.lang.Exception { InputReader in = new InputReader(System.in); PrintWriter out=new PrintWriter(System.out); int n=in.nextInt(); long k=in.ne...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; int i, a, b, c, best = 0, g; cin >> n >> k; cin >> a; g = 0; for (i = 1; i < n; i++) { cin >> b; if (a > b) g++; else { a = b; g = 1; } if (g >= k) { cout << a; return 0; } } ...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; import java.io.IOException; import java.io.InputStream; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.IntStr...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.Input...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; const int MX = 100000; int ini[505]; int cnt[505]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; long long k; int mx = 0; cin >> n >> k; for (int i = (1); i <= (n); i++) { cin >> ini[i]; mx = max(mx, ini[i]); } int p = ini[1]...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long k = sc.nextLong(); int[] a = new int[n]; int[] score = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); score[i] = 0; } int max...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, k; int a[600], st; cin >> n >> k; for (int i = 0; i < n; i++) { scanf("%d", &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]) { ...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,raw_input().split()) l=map(int,raw_input().split()) flag=1 d={} for i in range(1,n+1): d[i]=0 t=0 for i in range(1,len(l)): if l[t]>l[i]: d[l[t]]+=1 else: d[l[i]]+=1 t=i; if d[l[t]]==k: ans=l[t] flag=0 break if flag==0: print ans else: ...
PYTHON
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; import java.util.Map.Entry; import java.lang.Math; import java.math.BigInteger; public class Problem { class Pair { int x, y; Pair(int x, int y) { this.x = x; this.y = y; } } class Doc implements Comparable<Doc>{ int start; int rep; Doc(int start, int rep){ ...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
def play(a,gameNum,k): while gameNum<k: if a[0]>a[1]: a=[a[0]]+a[2:]+[a[1]] gameNum+=1 else: a=[a[1]]+a[2:]+[a[0]] gameNum=1 return a[0] n,k=map(int,raw_input().split()) a=map(int,raw_input().split()) if k>n: print max(a) else: p...
PYTHON
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, power[1000], s = 0, i, p, maxpower = 0; long long int k; cin >> n >> k; for (i = 0; i < n; i++) { cin >> power[i]; if (power[i] > maxpower) maxpower = power[i]; } p = power[0]; if (p == maxpower) cout << p << endl; else fo...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k = map(int,raw_input().split(" ")) arr = map(int,raw_input().split(" ")) wins = [0]*505 p = 0 flag = False for i in range(1,n): if arr[p] > arr[i]: wins[arr[p]] += 1 else: wins[arr[i]] += 1 p = i if wins[arr[p]] == k: flag = True break if flag: pr...
PYTHON
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#NYAN NYAN #β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ #β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ #β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–€β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–€β–„β–‘β–‘β–‘β–‘β–‘β–‘β–‘ #β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–‘β–‘β–„β–‘β–‘β–‘β–‘β–„β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘ #β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–ˆβ–„β–„β–‘β–‘β–„β–‘β–‘β–‘β–ˆβ–‘β–„β–„β–„β–‘β–‘β–‘ #β–‘β–„β–„β–„β–„β–„β–‘β–‘β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–€β–‘β–‘β–‘β–‘β–€β–ˆβ–‘β–‘β–€β–„β–‘β–‘β–‘β–‘β–‘β–ˆβ–€β–€β–‘β–ˆβ–ˆβ–‘β–‘ #β–‘β–ˆβ–ˆβ–„β–€β–ˆβ–ˆβ–„β–ˆβ–‘β–‘β–‘β–„β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–€β–€β–€β–€β–€β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘ #β–‘β–‘β–€β–ˆβ–ˆβ–„β–€β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–€β–‘β–ˆβ–ˆ...
PYTHON
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) a = list(map(int, input().split())) k1 = 1 a1 = max(a[0], a[1]) for i in range(2, n): if a1 > a[i]: k1 +=1 else: a1 = a[i] k1 =1 if k1 == k: break print(a1)
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import com.sun.org.apache.bcel.internal.generic.AALOAD; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; import java.util.stream.IntStream; import javafx.util.Pair; public class Main { static ...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.reflect.Array; import java.math.BigInteger; import java.net.InetAddress; import java.util.ArrayList; imp...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
playersCount, winNumber = [int(x) for x in input().split(' ')] players = [int(x) for x in input().split(' ')] winsCount = 0 max = 0 for i in range(1, playersCount): if players[max] > players[i]: winsCount += 1 else: winsCount = 1 max = i if winsCount >= winNumber: break print(players[max])
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
numero_de_pessoas, vitorias_nescessarias = map(int,input().split(" ")) fila = list(map(int,input().split(" "))) jogador_1 = fila.pop(0) jogador_2 = fila.pop(0) jogador_ganhando = -1 pontos = 0 while pontos < vitorias_nescessarias: if jogador_1 > jogador_2: if jogador_1 == jogador_ganhando: po...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) arr = list(map(int, input().split())) dic = {} curr = arr.pop(0) dic[curr] = 0 while(curr != n): if arr[0] == n: curr = n break if curr > arr[0]: arr.pop(0) dic[curr] += 1 else: curr = arr.pop(0) dic[curr] = 1 if dic[curr]...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) power = list(map(int, input().split())) results = {i: 0 for i in range(n)} maximal = max(power) max_index = power.index(maximal) for i in range(max_index): if power[i] < power[i + 1]: results[i + 1] += 1 ind = i + 1 while power[ind] < power[i]: results[i] += ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; using std::max; using std::min; using std::queue; using std::string; int main() { int n; cin >> n; long long k; cin >> k; int data[501] = { 0, }; for (int i = 1; i <= n; i++) { cin >> data[i]; } if (k > n - 1) { c...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k = [int(i) for i in input().split()] l = [int(i) for i in input().split()] d = l[0] t = 0 for i in range(1,n): if l[i] < d: t = t+1 else: t = 1 d = l[i] if t == k: break print(d)
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y = -1, i = 0; long long k, cnt = 0; cin >> n >> k; while (i < n) { cin >> x; if (y < x) { if (i != 0) cnt = 1; y = x; } else cnt++; if (cnt == k) break; i++; } cout << y; return 0; }
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
(n, k) = map(int, input().split()) a = list(map(int, input().split())) pobs = 0 curs = a[0] for i in range(1, n): if curs>a[i]: pobs+=1 else: curs = a[i] pobs = 1 if pobs==k: break print(curs)
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> int n; unsigned long long k; int a[500]; int main() { scanf("%d%I64u", &n, &k); for (int i = 0; i < n; i++) scanf("%d", a + i); unsigned long long ck = k; int cp = 0; for (int i = 1; i < n && ck > 0; i++) { if (a[cp] > a[i]) { ck--; } else { ck = k - 1; cp = ...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
from sys import stdout, stdin def play(line, n,k): player1 = line[0] player2 = 0 wins = 0 i = 1 while i < len(line): player2 = line[i] if player1 > player2: wins +=1 else: player1 = player2 wins = 1 if wins == k: i = le...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int a[505]; long long cnt[505]; int main() { int n; long long k; cin >> n >> k; int _max = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; _max = max(_max, a[i]); } if (a[1] == _max) return 0 * printf("%d", _max); int m = 1; for (int i = 2; i <= n; ...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author ankur */ public class Main...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().rstrip().split(' ')) players = list(map(int, input().rstrip().split(' '))) if n <= k: k = n - 1 playerWinner = 0 countUntilWin = 0 for i in range(1, n): tempComp = max(players[i], players[playerWinner]) if players[playerWinner] == tempComp: countUntilWin += 1 else: countUntilWin = 1 ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) A = [int(x) for x in input().split()] A.reverse() cc = A.pop() cr = 0 while len(A) > 0 and cc != n and cr < k: nc = A.pop() if nc > cc: cc = nc cr = 1 else: cr += 1 print(cc)
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
# table tennis from collections import deque def TableTennis(pw, power): wins = 0 power = deque(power) p1 = power.popleft() p2 = power[0] if len(power) == 1: if p1 > p2: print(p1) else: print(p2) else: while wins != pw[1]: if pw[1...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long a[300010], cnt[300010]; long long n, k, maxx; int main() { ios_base::sync_with_stdio(false); cin >> n >> k; for (int i = 1; i <= n; ++i) { cin >> a[i]; maxx = max(maxx, a[i]); } int pos = 1, cnt = 0; while (a[pos]...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
from collections import deque n, k = map(int, input().split()) num = list(map(int, input().split())) q = deque() kolvo = 0 fl = False wins = [0] * n for i in range(2, len(num)): q.append(num[i]) battle = [num[0], num[1]] while not k in wins and not fl: x = min(battle) pr = max(battle) pr1 = max(battle) ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, raw_input().split()) a = map(int, raw_input().split()) if k >= n: print(max(a)) else: i = 1 j = 0 wins = 0 while(j <= n): if a[j] > a[i]: wins+=1 if wins >= k: print(a[j]) break elif a[j] < a[i]: j+=1 i=j wins=1 i = (i+1) % n ...
PYTHON
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) a=list(map(int,input().split())) maximum=max(a) winner=count=0 while(count<k): cur=a[0] if cur==maximum: winner=cur break next=a[1] if next==maximum: winner=next break if cur>next: winner=cur a=[cur]+a[2:]+[next] count+=1 else: a=a[1:]+[cur] count=1 print(winner)
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
pp_num, wins_time = list(map(int, input().split())) pp = list(map(int, input().split())) cnt = 0 while cnt != wins_time: if pp[0] == max(pp): break if pp[0] > pp[1]: pp = [pp[0]] + pp[2:] + [pp[1]] cnt += 1 else: pp = pp[1:] + pp[0:1] cnt = 1 print(pp[0])
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; public class Hack_Earth { public static void main(String[] arg){ Scanner scan = new Scanner(System.in); int n=scan.nextInt(); long k=scan.nextLong(); int[] player = new int[n]; int max=-1; for(int i=0;i<n;i++){ player[i] = scan.nextInt(); if(player[i]>max) max = player[i]; ...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.u...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.ArrayList; import java.util.List; import java.util.Scanner; /** * Created by s326lab on 29/11/2017. */ public class Solution1 { public static void main(String[] args) { Scanner r = new Scanner(System.in); int n1 = r.nextInt(); long n2 = r.nextLong(); List<Integer>...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; long long k; cin >> n >> k; queue<int> q; for (int i = 0; i < n; i++) { int x; cin >> x; q.push(x); } int player = q.front(); q.pop(); long long score = 0; while (score < k) { if (player == n) break; int player2 = ...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k = [int(i) for i in input().split()] l = [int(i) for i in input().split(" ")] cur = 0 winner = l[0] if len(l) == 2: print(2) else: while cur < min(k,501): if l[0] > l[1]: win = l[0] winner = win lose = l[1] l = [l[0]] + l[2:] l.append(lose...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; public class Solution { public static void main(String[] args) throws java.lang.Exception { Scanner in = new Scanner(System.in); int n = in.nextInt(); long k = in.nextLong(); Queue<Integer> file = new LinkedList<>(); int max = 0; int a; f...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
from collections import deque n,k = map(int, input().rstrip().split()) if n<=k: k = n-1 power = deque(map(int, input().rstrip().split())) winner = power.popleft() winCount = 0 while winCount != k: enemy = power[0] compare = max(winner,enemy) if winner == compare: pow...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; class ListNode { public: ListNode() { power = 0; k = 0; next = NULL; } int power; int k; ListNode* next; }; class Queue { public: Queue() { head = NULL; tail = NULL; } ListNode* head; ListNode* tail; void dequeue() { ListNode* t...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> int n; long long k; int a[250050]; int cnt[510]; int main() { scanf("%d %I64d", &n, &k); for (int i = 0; i < n; ++i) scanf("%d", a + i); if (k > n * n) printf("%d\n", n); else { int s = 0, t = n - 1; for (;;) { if (a[s] > a[s + 1]) { if ((++cnt[a[s]]) >= k) { ...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.Scanner; import java.util.Arrays; public class Solution { public static void main(String [] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); long k=sc.nextLong(); long arr[]=new long [n]; for(int i=0;i<n;i++) { arr[i]=sc....
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
'''input 6 2 6 5 3 1 2 4 ''' n,k = map(int,raw_input().split()) a = map(int,raw_input().split()) if k >= n: ans = max(a) print ans else: loser = [] ans = max(a[0],a[1]) z = 1 for i in range(2,n): tmp = ans ans = max(ans,a[i]) a.append(min(ans,a[i])) if tmp == ans: z += 1 if tmp != ans: z = 1 if ...
PYTHON
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0), EPS = 1e-9; const int MX = 1 * 1e5 + 10; int N, M, k; int arr[MX]; int win[MX]; int main() { long long k; cin >> N >> k; for (int i = 1; i <= N; i++) cin >> arr[i]; int mx = *max_element(arr + 1, arr + 1 + N); int cur_max = arr[1], an...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int n, x, mx; long long k; vector<int> arr; int main() { cin >> n >> k; for (int i = 0; i < n; i++) { cin >> x; arr.push_back(x); } k = min(k, (long long)n); int cnt = 0; while (cnt < k) { if (arr[0] > arr[1]) { int tmp = arr[1]; arr.eras...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k = map(int,input().split()) powers = list(map(int,input().split())) max_power = max(powers) if n == 2 or k > n -2 or powers[0] == max_power: print(max_power) else: temp_max = 0 number_of_wins = 0 for a in powers: if a > temp_max: if not temp_max: number_of_win...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; void yesno(bool a) { if (a) { cout << "YES" << '\n'; } else { cout << "NO" << '\n'; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, k; cin >> n >> k; int arr[n]; int maxi = 0; int i; deque<int> q; fo...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k=list(map(int,input().split())) number=list(map(int,input().split())) if k>=n: print(max(number)) else : flag=0 i=0 while i < n-k+1: if i==0 and max(number[i:i+k+1])==number[i] : flag=1 print(number[i]) break elif i!=0 and max(number[i-1:i+k])==numb...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
arr = raw_input() n, k = map(int, arr.split(" ")) arr = raw_input() arr = map(int, arr.split(" ")) index = 1 count = 0 helper = [] pivot = arr[0] while index < n: if pivot > arr[index]: count += 1 if count == k: break else: pivot = arr[index] count = 1 index += 1 ...
PYTHON
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.math.BigInteger; import java.util.*; public class main { private static InputStream stream; private static byte[] buf = new byte[1024]; private static int curChar; private static int numChars; private static SpaceCharFilter filter; private static PrintWriter pw; private static long...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; deque<long long> a, b; int main() { ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); long long n, k, v, total = 0, ans; cin >> n >> k; cin >> v; a.push_front(v); for (int i = 1; i < n; i++) { cin >> v; b.push_back(v); } if (k > n) k = n - 1...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.Arrays; import java.util.Scanner; import java.util.UUID; public class water { public static Scanner cin=new Scanner(System.in); public static void main(String[] args) { // TODO Auto-generated method stub while (cin.hasNext()){ int n = cin.nextInt(); long k = cin.nextLong(); int[] a =...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; long long n, m, i, k, j, p, q, y; long long x[100001]; long long r() { long long p = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') { f = -1; } c = getchar(); } while (c >= '0' && c <= '9') { p = p * 10 + c - '0'; ...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; import java.io.*; import java.math.BigInteger; public class A2 { public static void main(String []args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); long k = sc.nextLong(); int[] arr = new int[n]; ArrayList<Integer> al = new ArrayList<Integer>(); ...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; const long long N = 4e5 + 5; const long long mod = 1e18; long long power(long long a, long long b) { if (b == 0) return 1LL; long long d = power(a, b / 2); d *= d; d %= mod; if (b % 2) d *= a; d %= mod; return d; } long long inv(long long a, long long MOD) { r...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
num_de_pessoas, num_de_vitorias = map(int, input().split()) habilidades = list(map(int, input().split())) aux = 0 if(num_de_pessoas <= 2): print(max(habilidades)) else: while aux < num_de_vitorias: if habilidades[0] > habilidades[1]: jogador = habilidades[1] habilidades.remove(jogador) habili...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
from sys import * from math import * n,k=map(int,stdin.readline().split()) a=list(map(int,stdin.readline().split())) if k>=n: print(max(a)) else: j=0 while j<k: if a[0]>a[1]: a.append(a.pop(1)) j+=1 else: a.append(a.pop(0)) j=1 print(a[0])
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; using lint = long long; int a[555]; void solve(istream& cin, ostream& cout) { int n; lint k; cin >> n >> k; for (int i = (0); i < int(n); ++i) { cin >> a[i]; } int mx = *max_element(a, a + n); int c = 0; int p = 0; for (int i = (0); i < int(n); ++i) { ...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k = map(long,raw_input().split()) powers = map(int,raw_input().split()) if(k >= n-1): print max(powers) else: strongest = powers[0] cWins = 0 for i in range(1,n): if cWins>=k: break if (powers[i] > strongest): strongest = powers[i] cWins=1 else: cWins+=1 print ...
PYTHON
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) A = [int(s) for s in input().split()] MAX = max(A) count = 0 player = 0 for i in range(n): if(A[i] == MAX): print(MAX) break elif(A[i] > player): if(i > 0): count = 1 player = A[i] else: count += 1 if(count == k): ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9; const ll mod = 1e9 + 7; const double pi = acos(-1); const double eps = 1e-6; int main() { deque<int> v; int n; ll k; cin >> n >> k; for (int i = 0; i < n; i++) { int x; cin >> x; v.push_back(x); } deque<int...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
size, req_Wins = [int(x) for x in input().split()] queue = [int(x) for x in input().split()] players = list(queue) undefeated = queue.pop(0) wins = 0 for x in range(size-1): challenger = queue.pop(0) if undefeated > challenger: wins += 1 else: undefeated = challenger wins = 1 if wins == req_Wins: ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().rstrip().split(' ')) players = list(map(int, input().rstrip().split(' '))) if(n <= k): k = n - 1 winner = 0 count = 0 for i in range(1, n): temp = max(players[i], players[winner]) if(players[winner] == temp): count = count + 1 else: count = 1 winner = i if(count == k): break ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); long n[] = Arrays.stream(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray(),...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; long long k; cin >> k; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } if (k > n - 1) { k = n - 1; } int ans = 0; for (int i = 0; i < n; i++) { int v = arr[i]; bool isAns = true; for (int j...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k = (int(x) for x in list(input().split(" "))) players = list(map(int,input().split())) if k > 500: print(max(players)) else: win=0 while win < k: if int(players[0]) > int(players[1]): players.append(players.pop(1)) win +=1 else: win = 0 ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; public class Main { public static Scanner scanner = new Scanner(System.in); public static int n; public static long winLimit; public static void main(String[] args) { String[] number = scanner.nextLine().split(" "); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); ...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.math.BigInteger; import java.util.*; public class l { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; import java.io.*; public class codeforces{ static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader() { reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; } public String next() { while (tokenize...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k = map(int,input().split()) a = list(map(int,input().split())) b = [0]*n if (a.index(max(a))<k) or (a.index(max(a))==0): print(max(a)) else: while max(b)<k: if a[0]>a[1]: b[0] = b[0]+1 x=a[1] y=b[1] a.remove(a[1]) b.remove(b[1]) ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; import java.io.*; import java.math.*; public class Main { static Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in))); public static void main(String[] args) { int n = input.nextInt(); long k = input.nextLong(); int maxPow = input.nextI...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int a[1005]; int kol[1005]; int main() { int n; cin >> n; long long k; cin >> k; int i0; for (int i = 1; i <= n; i++) { cin >> a[i]; a[n + i] = a[i]; } for (int i = 1; i <= 2 * n; i++) { for (int j = i + 1; j <= 2 * n; j++) if (a[i] > a[j])...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; long long int pow[n]; for (long long int i = 1; i <= n; i++) cin >> pow[i]; long long int MAX = pow[1], num = 0; for (long long int i = 2; i <= n && num < k; i++) { if (pow[i] < MAX) num++; else { ...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.Collections; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class TableTennis { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long wins = in.nextLong(); Queue<Integer> q = new LinkedList<Integer>(); ...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
//package codeforces.round443.div2; import java.io.*; import java.util.*; public class TableTennis { static class ProblemSolver { void solveTheProblem(InputReader in, PrintWriter out) { int n = in.nextInt(); long k = Long.parseLong(in.next()); if (k > n - 1) { ...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) a=list(map(int,input().split())) w=0 temp=a[0] m=max(a) while w<k: if temp<a[1]: a.remove(temp) a.append(temp) temp=a[0] w=1 else: w+=1 temp2=a[1] a.remove(temp2) a.append(temp2) if a[0]==m: temp=m b...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) v = list(map(int, input().split())) count = 0 previous = v[0] for i in range(1, n): if previous>v[i]: count+=1 else: previous = v[i] count = 1 if count==k: break print(previous)
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k = input().strip().split() n = int(n) k = int(k) day =0 a = list(map(int, input().strip().split())) score = 0 win = 0 if k >=n: print(n) else: for i in range(2 * n): if i !=0: if a[win] > a[i]: a.append(i) score +=1 else: a.append(win) win = i score =1 ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long k = in.nextLong(); LinkedList<Integer> q = new LinkedList<>(); for(int i = 0; i < n; i++) { q.add(in.nextInt()); } ...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) a = list(map(int, input().split())) win = 0 local = 0 for i in range(1, n): if a[local] > a[i]: win += 1 else: local = i win = 1 if win == k: break print(a[local])
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) a=list(map(int,input().split())) for i in range(n): if a[1]>a[0]: a[0],a[1]=a[1],a[0] if a[0]==max(a): print(a[0]);break else: try: if all(a[0]>a[j] for j in range(1,k+1)) : print(a[0]);break except:'blah!' x=a[0...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) l=list(map(int,input().split())) if k<=len(l): pos = l.index(max(l)) h= l[:pos] m=0 i=0 j=1 while i<pos and j<pos and m<k: if h[i]>h[j]: m+=1 j+=1 else : i=j j+=1 m=1 if m>=k: pri...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.LinkedList; import java.util.Optional; import java.util.Queue; import java.util.Scanner; public class TennisTable { public static long MaxQueueElement(Queue<Long> queue){ Optional<Long> max = queue.stream() .max(Comparable::compareTo); // if(max.isPresent()){ ...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import sys n, k = map(int, input().split()) a = list(map(int, input().split())) mx = max(a) num = a[0] if a[0] == mx: print(a[0]) sys.exit() count = 0 for i in range(1, n): if a[i] < num: count += 1 elif a[i] == mx: print(mx) sys.exit() else: count = 0 num = a[i] count = 1 if count == k: print(...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) l=list(map(int,input().split())) if l[0]==max(l[0:min(k+1,len(l))]): print(l[0]) else : for i in range (1,n): if l[i]==max(l[i:min(i+k,len(l))]): print (l[i]) break
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
from collections import deque def ping_pong(wins, numPlayers): pongers = deque(numPlayers) iterateCounter = 0 while(iterateCounter < len(pongers)): winsCounter = 0 fightsCounter = 0 pongerFought = [] while(True): fightsCounter += 1 if(pongers[0] > pongers[1]): if(pongers[0] > pongers[-1] and ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#!/usr/bin/python from math import ceil n, k = list(map(int, input().split())) p = list(map(int, input().split())) def sim(): global p a, p = p[0], p[1:] c = 0 while 1: b, p = p[0], p[1:] while a > b: c += 1 if c >= k: return a p.app...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int,input().split()) A = list(map(int,input().split())) C = [0] * n t = 0 p = 1 if k <= n: while True: if A[t] > A[p]: A.append(A[p]) if C[A[t]-1] == k-1: print(A[t]) break else: C[A[t]-1] += 1 else: ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; namespace Tzh { const int maxn = 1010; long long n, k, g[maxn]; void work() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> g[i]; if (k >= n) { cout << *max_element(g + 1, g + n + 1); return; } long long winner = 1, num = 0; for (int i = 2; i <= n; ...
CPP
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.math.BigInteger; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; import java.util.concurrent.LinkedBlockingDeque; public class Main { public static int maxn = 100005; public static Scanner in = new Scanner(System.in); public static void main(String[] args) { Queue<In...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
// package mainpackage; import java.io.*; import java.util.*; public class Main { public static void main(String... args) throws Exception { out = new PrintWriter(System.out); new Main().solve(); out.close(); } private static PrintWriter out; private BufferedReader reader; private StringTokenizer st...
JAVA
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
from collections import deque n, k = map(int, input().split()) guys = [int(x) for x in input().split()] wins = dict() queue = deque() max_power = max(guys) for guy in guys: wins[guy] = 0 queue.append(guy) cur = guys[0] queue.popleft() while cur != max_power and wins[cur] != k: enemy = queue.popleft() ...
PYTHON3
879_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 games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
JAVA