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
import sys n, k = map(int, input().split()) a = [int(i) for i in input().split()] if (k >= n - 1): print(max(a)); else: pref_max = a[0]; for i in range(n): s = a[i]; to = i + k + 1; if (s < pref_max): continue; else: pref_max = s; if (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
def tabletennis(n, cP): st = 0 for i in range(1, p): if st == nOW: return cP elif cP > n[i]: st += 1 else: cP = n[i] st = 1 return cP p, nOW = map(int, input().split()) n = input().split() n = list(map(int, n)) cP = n[0] print(table...
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() { long long n, k, arr[500], ck = 0; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> arr[i]; } long long j = arr[0]; for (int i = 1; i < n; i++) { if (j < arr[i]) { ck = 1; swap(j, arr[i]); } else { ck++; } if ...
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.*; public class A { public static void main(String ar[]) { Scanner s=new Scanner(System.in); int n=s.nextInt(); long k=s.nextLong(); int a[]=new int[n]; for(int i=0;i<n;i++) a[i]=s.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
import java.util.Collections; import java.util.LinkedList; import java.util.Scanner; /** * * @author arabtech */ public class TableTennis { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.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
// CodeForces Round #879 B train import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class TableTennis { int n; long k; int []a; // player powers int winPower; private void readData(BufferedReader bin) throws ...
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(' '))) s=0 e=0 f=1 if k>=n-1: e=max(a) else: while s<k: if a[0]>a[1] and f!=1: s+=1 c=a[1] del a[1] a.append(c) elif f==1: s+=1 c=max(a[0],a[1]) d=min(...
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()) nums=map(int,raw_input().split()) cons=max(nums[0],nums[1]) ct=1 ind=2 while ind<n: if ct==k: break #print "cons,nums[ind],ind",cons,nums[ind],ind if cons>nums[ind]: #print "cons>nums[ind]" ct+=1 #print "new ct",ct else: #print "ne...
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
a,b=map(int,input().split()) z=list(map(int,input().split())) p=z[0];s=0 for i in range(1,a): if z[i]<p:s+=1 else:s=1;p=z[i] if s>=b:break print(p)
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 solve() { long long n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vector<int> cnt(n + 1); deque<int> dq(a.begin(), a.end()); for (int i = 0; i < n - 1; ++i) { if (dq[0] > dq[1]) { swap(dq[0], dq[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
if __name__ == '__main__': nk = input().split() n = int(nk[0]) k = int(nk[1]) a = list(map(int, input().rstrip().split())) winner = 0 if (k > n): winner = max(a) else: q = [] for i in a: q.append(i) wins = 0 winner = q[0] q.pop(0) #print (q) while (wins != k): front = q[0] if (winn...
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 = [*map(int, input().split())] current = 0 ans = a[0] i = 1 while i < n : if ans > a[i]: current += 1 else: current = 1 ans = a[i] if current == k: break i += 1 print(ans)
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,m=map(int,input().split()) l=list(map(int,input().split())) ka=max(l[0],l[1]) c=1 for i in range(2,n): if(c==m): break if(l[i]>ka): ka=l[i] c=1 else: c=c+1 print(ka)
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=[int(i) for i in raw_input().split()] l=[int(i) for i in raw_input().split()] m=max(l) if l[0]==m or l[1]==m: print max(l[0],l[1]) else: if l[0]>l[1]: wt=0 else: wt=1 cw=1 for i in range(2,n): if l[i]==m: print m break elif l[i]>l[wt]: ...
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.util.Scanner; import java.util.StringTokenizer; public class B { public static Scanner sc = new Scanner(System.in); public static StringTokenizer st; public static void main(String[] args) { loadLine(); int N = getInt(); long K = getLong(); int[] a = new int[N]; int toload = 0; // properly load...
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 winner = 0 winCount = 0 for i in range(1, n): tempComp = max(players[i], players[winner]) if players[winner] == tempComp: winCount += 1 else: winCount = 1 winner = i if winCount == k: br...
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()) l = map(int, raw_input().split()) m = max(l) ans = -1 curr = l[0] run = 0 if curr == m: ans = m else: for j in l[1:]: if j == m: ans = m break else: if j < curr: run += 1 if run == k: ...
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
firstInput = input().split() n = int(firstInput[0]) k = int(firstInput[1]) players = list(map(int, input().rstrip().split())) numOfWins = 0 temporaryArray = [] currentPlayerWinner = players[0] if n == 2: if players[0] > players[1]: print(players[0]) else: print(players[1]) elif k > n**2: ...
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.PrintWriter; import java.util.Collection; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Queue; import java.io.BufferedReader; import java.util.LinkedList...
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
R=lambda:list(map(int,input().split())) n,k=R() a=R() c=[0 for i in range(n+1)] while 1>0: if a[0]>a[1]: a[0],a[1]=a[1],a[0] a=a[1:]+a[:1] c[a[0]]+=1 if a[0]==n or c[a[0]]>=k: print(a[0]) 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
n,k = map(int,input().split()) a= list(map(int,input().split())) if k>=n: print(max(a)) else: win_player = a[0] win_streak = 0 for power in a[1:] : if win_player > power: win_streak +=1 else: win_player = power win_streak = 1 if win_streak ==k: break print(win_player)
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.Scanner; public class TableTennis { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int n = s.nextInt(); long win = s.nextLong(); int f = 0; int x = 0; int[] a = new int[n]; for (int i = 0;i < n;i++) { int l = s.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
# -*- coding: utf-8 -*- import math import collections import bisect import heapq import time import random import itertools import sys """ created by shhuan at 2017/10/28 15:51 """ N, K = map(int, input().split()) P = [int(x) for x in input().split()] if K >= N-1: print(max(P)) else: if P[0] > max(P[1: 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
''' Codeforces: B. Table Tennis ''' def queue(list_, k): wins = 0 while wins < k: if int(list_[0]) > int(list_[1]): index = 1 wins+=1 else: index = 0 wins = 1 list_.append(list_[index]) list_.pop(index) return list_[0] fi...
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 length, backToBack; scanf("%d%d", &length, &backToBack); int count = 0; long long winnerForce; scanf("%lld", &winnerForce); for (int i = 1; i < length; i++) { long long force; scanf("%lld", &force); if (count < backToBack) { if...
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
nk = input().split() n = int(nk[0]) k = int(nk[1]) players = [int(i) for i in input().split()] if k>n: print(max(players)) else: playing = players[0:2] queue = players[2:] win = False wins = 0 while wins<k: if playing[0]>playing[1]: wins+=1 queue.append(playing[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; int n; long long k; int power[555]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k; for (int i = 0; i < n; i++) cin >> power[i]; queue<int> line; for (int i = 2; i <= n - 1; i++) line.push(i); int p1 = 0; int p2 = 1; int consec...
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()) arr = deque(list(map(int, input().split()))) major = arr.popleft() cnt = 0 while cnt < min(k, n): item = arr.popleft() if item < major: arr.append(item) cnt += 1 else: cnt = 1 arr.append(major) major = ...
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
# your code goes here n,k = input().split() n=int(n) k=int(k) a = list(map(int,input().split())) count=0 i=0 j=1 while True: if(k>n): print(max(a)) break if(a[i]>a[j]): count+=1 if(count==k): print(a[i]) break a.append(a[j]) a.remove(a[j]) else: a.append(a[i]) a.remove(a[i]) count=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()) m=list(map(int,input().split())) a=max(m) d=max(m[0],m[1]) s=1 for i in m[2:]: if i==a: d=a break if i>d: d=i s=1 else: s+=1 if s==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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.StringTokenizer; import javax.print.attribute.standard.MediaSize.ISO; public class B { static int n ; static long K ; ...
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
firstInput = input().split(" ") numberPlayers = int(firstInput[0]) numberWinsNecessary = int(firstInput[1]) powerPlayers = [] secondInput = input().split(" ") for i in range(numberPlayers): powerPlayers.append(int(secondInput[i])) lastWinner = powerPlayers[0] wins = 0 while wins < numberWinsNecessary and len(p...
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
#http://codeforces.com/problemset/problem/879/B from collections import deque inp = lambda: map(int, input().split()) n, k = inp() player = deque(list(inp())) win = 0 while win < k: if player[0] > player[1]: win += 1 winner = player.popleft() loser = player.popleft() player.append...
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())) get = 1 ans = max(a[0], a[1]) for i in range(2, n): if (ans > a[i]): get +=1 else: ans = a[i]; get =1 if (get == k): break print(ans)
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
s1 = input() n = int(s1.split()[0]) k = int(s1.split()[1]) s2 = input() pl = [] for i in s2.split(): pl.append(int(i)) rang = True c = 0 p1 = pl[0] j=1 while(c!=k): if j==n: break if p1>pl[j]: j+=1 c+=1 else: p1 = pl[j] j+=1 c=1 print(p1)
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.*; public class _879B { static void empty(int[] a, int i){ for (int j = 0; j < a.length; j++) { if (j == i) continue; a[j] = 0; } } public static void main(String[] args){ Scanner in = new Scanner(System.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
#include <bits/stdc++.h> using namespace std; int main() { int n, a; long long int k; int wins = 0; int cur; cin >> n >> k; cin >> cur; for (int i = 1; i < n; ++i) { cin >> a; if (a > cur) { cur = a; wins = 1; } else { ++wins; } if (wins == k) { cout << cur; ...
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()) l = list(map(int,input().split())) if k>=n-1: print(max(l)) else: count = 0 max = l[0] for i in range(1,n+k+1): if max>l[i]: l.append(l[i]) count += 1 else: l.append(max) max = l[i] count = 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; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ; int n; long long int k; cin >> n >> k; int a[n], maxi = 0, p; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > maxi) { maxi = a[i]; p = i; } } if (p == 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
from collections import deque p, k = list(map(int, input().split())) players = deque(list(map(int, input().split()))) wins = {} for i in players: wins[i] = 0 max_p = max(players) index_max = players.index(max_p) if index_max <= k: print(max_p) else: while True: if players[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
def tableTennis(wins, players): p = players idx = 0 while idx < len(p): win_count = 0 has_fought = [] fight_count = 0 while True: fight_count += 1 if(p[0] > p[1]): if fight_count == 1 and p[0] > p[-1]: win_count += 2 else: win_count += 1 has_fought.append(p[1]) if win_cou...
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
def main(): n, k = map(int, raw_input().split()) arr = list(map(int, raw_input().split())) if k >= n: print max(arr) return last_winner = 0 curr_streak = 0 for i in range(1, n): if arr[i] > arr[last_winner]: winner = i else: winner = last_...
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; int a[600], st; long long 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]) ...
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.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import static java.lang.Math.*; public class TableTennis implements Closeable { private InputReader 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
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; long long pla, num, a, b, cnt = 0; cin >> a; for (long long i = 1; i < n; i++) { cin >> b; if (a > b) cnt++; else cnt = 1, a = b; if (a == n or cnt == k) { cout << a << endl; break...
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
userInput = input() inputL1P1 = int(userInput.split()[0]) inputL1P2 = int(userInput.split()[1]) userInput2 = input() inputArray = userInput2.split() inputArray = [ int(x) for x in inputArray ] winCounter = 0 for i in range (inputL1P1): if i == inputL1P1: break if winCounter == inputL1P2: break if inputArray[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.*; import java.io.*; public class Main { static InputReader in; static PrintWriter out; public static void main(String[] args) { in = new InputReader(); out = new PrintWriter(System.out); solve(); out.close(); } static void solve() { int n =...
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 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long k = in.nextLong(); int[] a = new int[n]; for(int i=0;i<n;i++) a[i] = in.nextInt(); int max = Math.max(a[0], a[1]),ans = 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
import queue N, K = map(int, input().split()) A = list(map(int, input().split())) Q = queue.Queue() if(K > N): print(max(A)) else: B, W = A[0], 0 for i in range(1, N): Q.put(A[i]) while True: top = Q.get() if B > top: Q.put(top) W += 1 else: Q.put(B) B, W = top, 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 = [int(x) for x in input().split()] power = [int(x) for x in input().split()] achou = False winner = 0 if k >= len(power): winner = max(power) achou = True vitorias = 0 while not achou: if power[0] > power[1]: temp = power[0] power.append(power[1]) power.pop(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
import math n , k = map (int , input().split()) l = list( map(int , input().split())) ll= list(l+l) cnt = int (0) if(k>= n-1 ):print (n) else: for i in ll: if(cnt==0): if(i==max (ll[cnt:cnt+k+1])): print(i) break elif(i==max (ll[cnt-1:cnt+k])): print(i) break cnt+=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.Scanner; public class tableTennis{ public static void main(String[] args){ Scanner kbd = new Scanner(System.in); int n = kbd.nextInt(); long k = kbd.nextLong(); int answer = kbd.nextInt(); int b = 0; for(int i = 1; i < n; i++){ int a = kbd.nextInt(); if(b >= k){ break; ...
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 nums = input().split(' ') powers = input().split(' ') n = int(nums[0]) k = int(nums[1]) queue = [] #result = -1 for i in range(n): queue.append(int(powers[i])) #result = max(result, num) ans = queue[0] s = 0 for j in range(1,n): if s >= k: #print(ans) ...
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 main() { int qu[100009], head = 1, tail = 0; long long n, k; int x; scanf("%lld%lld", &n, &k); int mmax = 0; for (int i = 1; i <= n; i++) { scanf("%d", &x); if (x > mmax) mmax = x; qu[++tail] = x; } if (k >= n - 1) { printf("%d\n", mmax); } else { long ...
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; const int N = 2005; void solve() { long long int n, k; cin >> n >> k; long long int a[n]; for (long long int i = 0; i < n; i++) cin >> a[i]; if (k >= n) { cout << *max_element(a, a + n); } else { deque<long long int> q; for (int i = 2; i < n; i++) q....
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.Queue; import java.util.LinkedList; import java.lang.Math; public class Main{ public static void main(String args[]){ Scanner input = new Scanner(System.in); String[] nk = (input.nextLine()).split(" "); long n = Long.parseLong(nk[0]); long k = Long.parseLong(nk[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
inp=lambda:map(int,input().split()) n,k=inp() a=list(inp()) if(k>n): print(max(a)) quit() line=[0]*501 win=[0]*501 for i in range(n): line[i]=i max_win=0; for i in range(n+k+2): if(a[line[0]]>a[line[1]]): win[line[0]]+=1 if win[line[0]]>max_win: max_win=win[line[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
from collections import deque nk = input().split() n = int(nk[0]) k = int(nk[1]) if n<=k: k = n-1 power = deque(map(int, input().rstrip().split())) winner = power.popleft() winCount = 0 while winCount != k: enemy = power[0] if winner > enemy: power.append(enemy) ...
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() { ios_base::sync_with_stdio(false); int n; cin >> n; long long k; cin >> k; vector<int> a(n); int i; int mx_pos = -1; for (i = 0; i < n; i++) { cin >> a[i]; if (a[i] == n) { mx_pos = i; } } int p1 = -1, p2 = -1; long long...
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 = [int(p) for p in input().split()] q = deque([int(p) for p in input().split()]) curr = q[0] count = 0 while k > count: p1 = q.popleft() p2 = q.popleft() win = max(p1, p2) los = min(p1, p2) if win == curr: count += 1 else: curr = win cou...
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 funcao(queue, k): if k >= len(queue): return max(queue) win = queue.popleft() cont = 0 while cont < k: prox = queue.popleft() if win >= prox: queue.append(prox) cont += 1 else: queue.append(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; int n; long long k; int main() { cin >> n >> k; long long b; long long c = 0, a; cin >> b; for (int i = 2; i <= n; i++) { cin >> a; if (b > a) c++; else { b = a, c = 1; } if (c == k) { cout << b; return 0; } } co...
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.*; public class Codeforces { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextTok...
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,raw_input().split()) a = map(int,raw_input().split()) if k>=n-1: print n else: nbw = 0 toplay = 0 chall = 1 while nbw<=k: if a[toplay]==n or nbw==k: print a[toplay] break if a[toplay]>a[chall]: nbw+=1 else: toplay = chall nbw = 1 chall +=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.util.Scanner; import java.util.Deque; import java.util.LinkedList; public class Table_Tennis { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); int count = scan.nextInt(); long loop = scan.nextLong(); if (loop > count) { loop ...
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
while True: try: n,k=map(int,input().split()) a=input().split() ans=int(a[0]) st=0 for i in range(1,n): if st>=k: break if ans>int(a[i]): st+=1 else: st=1 ans=int(a[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
import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class duh { public static void main(String[] args) { Scanner ob = new Scanner(System.in); int n=ob.nextInt(); long k=ob.nextLong(); int[] ar=new int[n]; for(int 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
n, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] wins = [] for i in range(n): wins.append(0) while True: if a[0] > a[1]: a.append(a[1]) del a[1] wins.append(wins[1]) del wins[1] wins[0] += 1 else: a.append(a[0]) del a[...
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 fractions import gcd n,k = map(int,raw_input().split()) s = map(int,raw_input().split()) i = [0]*n a = 0 b = 1 if k<n: while max(i)<k: if s[a]>s[b]: b = (b+1)%n i[a]+=1 else: a=b i[a]+=1 b = (b+1)%n #print a,b print s[a] else: print max(s)
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
R=lambda:map(int,raw_input().split()) n,k=R() a=R() w,i,c,m=0,1,0,max(a) while w<k and a[0]!=m: if a[0]<a[i]: w=0 a[0],a[i]=a[i],a[0] w+=1 i+=1 if i>=n: i=1 print a[0]
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, powers[510]; long long k; vector<int> vec1; cin >> n >> k; for (int i = 0; i < n; i++) { scanf("%d", &powers[i]); vec1.push_back(powers[i]); } if (k >= n - 1) printf("%d\n", *max_element(powers, powers + n)); else { int nu...
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()) t =list(map(int,input().split())) a=t[0] p=0 h=-1 for j in range(n): if a>t[j]: p+=1 elif a<t[j]: a=t[j] p=1 if p==k: h=a break if h!=-1: print(h) else: print(max(t))
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
# @author Nayara Souza # UFCG - Universidade Federal de Campina Grande # AA - Basico n, k = list(map(int, input().split())) x = list(map(int, input().split())) count = 0 j = x[0] for i in range(1,n): if count >= k: break if j > x[i]: count += 1 else: j = x[i] count...
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())) maxa = max(a) if len(a) <= k: print(maxa) else: curr = a[0] j = 0 for i in range(1, len(a)): if j == k: print(curr) break if a[i] == maxa: print(maxa) break if a[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 namespace std; template <typename T> void takearray(vector<T> &a, long long int n) { T y; for (long long int i = 0; i < n; i++) { cin >> y; a.push_back(y); } } template <typename T> void print1d(vector<T> &a) { for (long long int i = 0; i < a.size(); i++) { cout << 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
from collections import Counter n, k = map(int, input().split()) a = map(int, input().split()) d = Counter() p1 = next(a) for p2 in a: if p1 > p2: d[p1] += 1 else: d[p2] += 1 p1 = p2 if d[p1] >= k: print(p1) exit(0) print(n)
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{ Reader.init(System.in); int n = Reader.nextInt(); long k = Reader.nextLong(); int[] players = new int[n]; for (int i = 0; i < players.length; 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.util.Scanner; public class TableTennis { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long k = sc.nextLong(); int p = sc.nextInt(); long c = 0; for(int i = 1; i < n; i++) { int r = sc.nextInt(); if(r > p) { c = 1; p =...
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; cin >> n >> k; int winner = 0; long long fk = k; for (int i = 0; i < n; i++) { int temp; cin >> temp; if (winner > temp) { fk--; if (fk == 0) break; } else { winner = temp; fk = k; if (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
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long mod2 = 998244353; const int inf = 0x3f3f3f3f; const double tiaohe = 0.57721566490153286060651209; long long oula(long long x) { long long res = x; for (int i = 2; i <= x / i; ++i) { if (x % i == 0) { res = res / 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
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } long long int lcm(long long int a, long long int b) { return ((a * b) / gcd(a, b)); } void scanint(int &x) { register int c = getchar(); x = 0; int neg = 0; for...
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=int(input()) # n,k=map(int,input().split()) # arr=list(map(int,input().split())) #ls=list(map(int,input().split())) #for i in range(m): # for _ in range(int(input())): #from collections import Counter #from fractions import Fraction #s=iter(input()) from collections import deque n,k=map(int,input().split()) arr=lis...
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(' ')) massiv = list(map(int, input().split(' ') )) def sila_v_igroka(mas,k): x=0 sila=0 if len(mas)<=k: return(max(mas)) while x!=k : if mas[0]>mas[1]: sila=mas[0] mas=[mas[0]]+mas[2:]+[mas[1]] x+=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; int main() { unsigned long long int i, n, k; cin >> n >> k; deque<unsigned long long int> P; unsigned long long int temp; for (i = 0; i < n; i++) { cin >> temp; P.push_back(temp); } if (n == 2) { cout << max(P[0], P[1]); return 0; } unsigne...
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 = [int(i) for i in input().split()] d = a[0] cnt = 0; mx = d for i in range(1,n) : mx = max(mx,a[i]) if k >= n : print (mx) exit() for i in range(1,n) : if a[i] < d : cnt += 1 else : cnt = 1 d = a[i] if cnt == 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
n,k=map(int,raw_input().split()) a=map(int,raw_input().split()) if k>=n-1: print n else: x=0 y=0 z=1 while x<=k: if a[y]==n or x==k: print a[y] break if a[y]>a[z] : x+=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
from collections import deque n, k = map(int, input().split()) a = deque(map(int, input().split())) f = a.popleft() s = a.popleft() cnt = 0 while cnt < k: if f > s: cnt += 1 a.append(s) s = a.popleft() else: cnt = 1 a.append(f) f, s = s, a.popleft() if f == n...
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
inp=input(); inp=inp.split(); n=int(inp[0]); k=int(inp[1]) d=input(); d=d.split(); d=[ int(d[x]) for x in range(n) ] tot=[ 0 for _ in range(505) ] i=0 ans=d[0] for i in range(1,n): if ans>d[i]: tot[ans]+=1 else: ans,d[i]=d[i],ans tot[ans]+=1 if tot[ans]==k: print(ans) ...
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 * Q = deque() n, k = [int(x) for x in input().split()] Q.extend([int(x) for x in input().split()]) cnt = 0 maximo = max(list(Q)) last_winner = -1 while True: u = Q.popleft() v = Q.popleft() loser = min(u, v) winner = max(u, v) if winner == last_winner: cnt += 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.ArrayDeque; import java.util.Arrays; import java.util.Deque; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] arr = new int[n]; Deque<Integer> deque = n...
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, w = map(int, input().split()) arr = list(map(int,input().split())) winner = arr[0] consecutivesWins = 0 for i in range(1, n): if(consecutivesWins == w): break elif (winner < arr[i] ): winner = arr[i] consecutivesWins = 1 else: consecutivesWins += 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
n ,k = map(int , input().split()) arr = list(map(int,input().split())) if k >= n: print(max(arr)) else: len = len(arr) cnt = 0 prev_ans = -1 ans = 0 for idx in range(2000): idx = idx + 1 mini = min(arr[idx],arr[idx - 1]) maxi = max(arr[idx],arr[idx - 1]) if arr[id...
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
entrada = list(map(int,input().split())) jogo = list(map(int,input().split())) i = jogo[0] j = 1 temp = 0 vitorias = 0 cond = True if(entrada[1] >= max(jogo)): temp = max(jogo) cond = False jogo.append('X') while(cond): if(vitorias >= entrada[1] or jogo[j] == 'X'): break elif (i > jogo[j]): ...
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.ArrayDeque; import java.util.Deque; import java.util.Scanner; public class B879 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); int n = scan.nextInt(); long k = scan.nextLong(); Deque<Integer> dq = new ArrayDeque<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
import java.util.*; import java.io.*; import java.math.*; public final class Solution { public static void main(String[] args) { Reader input = new Reader(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int n = input.nextInt(); long k = input.nextLong(); Arr...
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(" ")) numbers = list(map(int, input().split(" "))) best = max(numbers) def f(): if k >= n: print(best) return else: current_best = numbers[0] if numbers[0] == best: print(best) return winners = 0 for ...
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
# -*- coding: utf-8 -*- """ Created on Mon Sep 16 09:32:34 2019 @author: avina """ n,k = map(int, input().split()) l = list(map(int, input().split())) a = l[0] win = 0 for i in range(1,n): if a > l[i]: win+=1 else: a = l[i] win = 1 if win == k: break print(a)
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 gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } bool isPrime(long long n) { long long c; if (n <= 1) return false; c = sqrt(n); for (int i = 2; i <= c; i++) if (n % i == 0) return false; return true; } const long long N = 1e6 + 7; lon...
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 a[550], book[550]; int main() { int n; long long k; while (~scanf("%d%lld", &n, &k)) { memset(book, 0, sizeof(book)); int i, j, max = -1; for (i = 0; i < n; i++) { scanf("%d", &a[i]); if (a[i] > max) { max = a[i]; } } int head, end = 0, fl...
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; ifstream fin("input.txt"); ofstream fout("output.txt"); inline void boostIO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { boostIO(); long long int n, k; cin >> n >> k; vector<long long int> A(n * 2); for (int i = 0; i < (n); ++i) ...
CPP