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 java.util.ArrayDeque; import java.util.Queue; import java.util.Scanner; public class codeforces { public static void main(String[] args) { TaskB Solver = new TaskB(); Solver.Solve(); } public static class TaskB { public void Solve() { ...
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 = input().split() jogadores = input().split() jogadores = [int(x) for x in jogadores] if int(k) > int(n): vencedor = max(jogadores) else: vitorias = 0 while vitorias < int(k) : vencedor = jogadores[0] if vencedor > jogadores[1]: jogadores.append(jogadores.pop(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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class JavaStructures { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Queue<Integer> queue...
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; struct temp { int inp, vicCount; }; int main() { long long n, k; cin >> n >> k; struct temp ss[n + 2]; int maxn = 0; deque<temp> dq; for (int i = 0; i < n; i++) { cin >> ss[i].inp; ss[i].vicCount = 0; dq.push_back(ss[i]); maxn = max(maxn, ss[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
#http://codeforces.com/problemset/problem/879/B inp = list(map(int,input().split() )) games = inp[1] players = list(map(int,input().split())) best= players[0] victory = 0 if(games>=len(players)-1): print(max(players)) else: for x in players[1:]: if x < best: victory += 1 else: best = x victory = 1 if ...
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
num_wins = int(input().split(" ")[1]) num_players = input().split(" ") sub = int(num_players[0]) num_players.pop(0) wins = 0 check = int(num_players[0]) while wins < num_wins: main = int(num_players[0]) if sub > main: wins+=1 if wins == num_wins: print(sub) break num_players.pop(0) num_pl...
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; long long n, k, m, shu[6000]; int main() { scanf("%lld%lld", &n, &k); long long imax = 0; queue<long long> q; for (long long i = 1; i <= n; i++) { scanf("%lld", &shu[i]); q.push(shu[i]); imax = max(imax, shu[i]); } if (n <= k) { printf("%d\n", im...
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 Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long k = sc.nextLong(); int[] P = new int[n]; long cnt = 0; for(int i=0;i<n;i++){ P[i] = sc.nextInt(); } int max = P[0]; for(int i=1;i<n;i++){ if(P[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.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class P1 implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int nu...
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
g, f = map(int, input().split()) mas = list(map(int, input().split())) k = max(mas) q = 0 n = mas[0] for i in range(g): if mas[i] == k: print(mas[i]) break if mas[i] > n: n = mas[i] q = 1 else: if i != 0: q += 1 if q == f: print(n) brea...
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.LinkedList; public class B { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] l = br.readLine().split(" ")...
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()) power=list(map(int,input().split())) if k>=n-1: maxx=max(power) print(maxx) else: myMap={} done=0 for i in range(n): myMap[power[i]]=0 while(True): if power[0]>power[1]: myMap[power[0]]+=1 temp=power.pop(1) power.ap...
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 # def p(case, res): # print "Case #"+str(case+1)+": "+str(res) n, k = map(int, raw_input().split()) powers = map(int, raw_input().split()) currPower = powers[0] count = 0 for power in powers[1:]: if count == k: break if power < currPower: count += 1 else: count = 1 currPower = power print currP...
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
'''input 5 2 1 4 3 5 2 ''' n, k = map(int, input().split()) a = list(map(int, input().split())) if k > len(a): print(max(a)) else: w = 0 while w < k: if a[0] < a[1]: a.append(a.pop(0)) w = 1 else: w += 1 a.append(a.pop(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
import java.util.*; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long k = sc.nextLong(); long p = sc.nextLong(); long c = 0; for (long i = 0; i < n-1; i++) { long newP = s...
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()) power = list(map(int, input().split())) wins = 0 for i in range(n): for j in range(i+1, n): if power[j] < power[i]: wins += 1 else: break if wins >= k: print(power[i]) exit(0) wins = 1 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
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 1; long long k, cnt, tmp; long long a[MAXN]; int main() { int i, n; cin >> n >> k; for (i = 0; i < n; i++) { cin >> a[i]; } if (n == 2) { cout << max(a[0], a[1]); } else if (k < n) { while (cnt < k) { if (a[0] > a[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
first = input() n,k = [(int)(x) for x in first.split()] n = (int)(n) k = (int)(k) second = input() nums = [(int)(x) for x in second.split()] players = [nums[0],nums[1]] nums.pop(0) nums.pop(0) if(n==2): print(max(players)) else: while(1): winner = max(players) if(len(nums) <= k-1 and max(nu...
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 import os import random import re import sys playerWins = input().split() player = int(playerWins[0]) wins = int(playerWins[1]) powerValue = list(map(int, input().rstrip().split()[:player])) a=0 checker = [] if wins > 1000: wins = 1000 while len(checker) < wins: if powerValue[a] > powerValue[a+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()) powers = list(map(int, input().split())) max_power = max(powers) def get_winner(): i = 0 size = len(powers) extra = 1 while True: if powers[i] == max_power: return powers[i] for j in range(i + 1, min(i + k + extra, size)): if...
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; cin >> n; long long k; cin >> k; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int x = a[0], c = 0; for (int i = 1; i < n; i++) { if (a[i] < x) c++; else { x = a[i]; c = 1; } if (c == k || 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()) a=list(map(int,raw_input().split())) if a[0]>a[1]: a[0],a[1]=a[1],a[0] def cal(a,n,k): maxi=0 cnt=0 for i in a: if i>maxi: cnt=1 maxi=i else: cnt+=1 if cnt==k: print maxi ret...
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 math import* n, k = [int(i) for i in input().split()] gg = [int(i) for i in input().split()] cnt = 0 comper = gg[0] for i in range(1, len(gg)): if cnt >= k: print(comper) break if comper > gg[i]: cnt += 1 else: comper = gg[i] cnt = 1 else: print(max(gg)) ...
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.Queue; import java.util.Scanner; public class CF_443B { public static void main(String[] args) { new CF_443B().run(); } class Value { public int value; public long count; public Value(int value, long count) { this.value = value; this.count = count; } ...
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 math import re import os import string import sys def ria(): return [int(i) for i in input().split()] def ri(): return int(input()) def rfa(): return [float(i) for i in input().split()] eps = 1e-9 def is_equal(a, b): return abs(a - b) <= eps def distance(p0, p1): return math.sqrt(...
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
numofplayers, neededwins = [int(x) for x in input().split()] line = [int(x) for x in input().split()] players = list(line) champ = line.pop(0) #print(champ) #print(line) wins = 0 for x in range(numofplayers-1): newbie = line.pop(0) if champ > newbie: wins = wins + 1 else: champ = newbie wins = 1 if 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
#include <bits/stdc++.h> using namespace std; int a[111111]; int main() { int n; long long m; scanf("%d%lld", &n, &m); int d = 0; for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); int ans = a[1]; long long st = 0; for (int i = 2; i <= n; ++i) { if (st >= m) break; if (ans > a[i]) st++; ...
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())) high = max(a.pop(0), a.pop(0)) if n == 2: run = False else: run = True try: while run: for i in range(k-1): if a[i] > high: high = a[i] a = a[i+1::] break el...
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 { private int n; private long k; private int a[]; private Scanner sc; public TableTennis() { sc=new Scanner(System.in); do{ n=sc.nextInt(); k=sc.nextLong(); }while(n<2 || n>500 || k>Math.pow(10, 12)); a=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
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayDeque; import java.util.StringTokenizer; public class Table_Tennis { public static void main(String[] args) throws IOException { ...
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 B { Reader in; PrintWriter out; int i = 0, j = 0; void solve() { //START// int n2 = in.nextInt(); long n = (long)n2; long k = in.nextLong(); long top = 0; ArrayDeque<Long> line = new ArrayD...
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 n, A[505], mx = -1, B[505], tut, vis[505], tp[505]; vector<int> v[50][50]; long long int k; int main() { scanf("%d %lld", &n, &k); for (int i = 1; i <= n; i++) scanf("%d", &A[i]); for (int i = 1; i <= n; i++) { if (A[i] > mx) { mx = A[i]; tut = 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 k; int pre, a[500], wins[501], mx = 0, n, i; int main() { scanf("%d%lld", &n, &k); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); mx = max(a[i], mx); } if (k >= n) { printf("%d\n", mx); return 0; } pre = a[0]; for (i = 1; wins[pre]...
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())) d = {} mx = L[0] for i in range(1, n): mx = max(mx, L[i]) if mx in d: d[mx] += 1 else: d[mx] = 1 if d[mx] == k: print(mx) exit() print(mx)
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; string s; long long n, a[100005], b[100005], m; void solve() { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; long long k = max(a[1], a[2]), ans = 0, p = 1; for (int i = 3; i <= n; i++) { if (a[i] > k) { k = a[i]; p = 1; } 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
tamanho, quantidades_vit = map(int, input().split()) desafiantes = list(map(int, input().split())) maior = max(desafiantes) if quantidades_vit >= tamanho: print(maior) else: vencedor_atual = None cont = 0 while True: if cont >= quantidades_vit or vencedor_atual == maior: print(ven...
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.io.PrintWriter; import java.util.StringTokenizer; public class CF8 { final static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); final static PrintWriter pw = new PrintWriter(System.o...
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()) arr=map(int,raw_input().split()) count={} for i in arr: count[i]=0 if k>=n-1: print max(arr) else: while(1): if arr[0]>arr[1]: count[arr[0]]+=1 count[arr[1]]=0 if count[arr[0]]>=k: print arr[0] break...
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 org.omg.CORBA.INTERNAL; import org.omg.PortableInterceptor.INACTIVE; import java.io.*; import java.util.*; import java.lang.*; import java.math.*; public class Solution { static class TaskG { private void solve(int test, FastScanner in, PrintWriter out) { int n = 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
ar = map(int, raw_input().split()) flag = 0 fl = 0 ii = 0 a = map(int, raw_input().split()) i = 0 ma = 0 while i< ar[0]: count = 0 if i >0 : count = 1 if ma < a[i]: ma = a[i] for j in range(i+1,ar[0]): if a[j] < a[i]: count+=1 else: break if count >=ar[1]: print a[i] flag = 1 break else: 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
import java.util.Scanner; import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextInt(); String kk = sc.next(); long k = Long.parseLong(kk); Queue<Integer> intQueue = new LinkedList(); 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
#include <bits/stdc++.h> using namespace std; long long a[100005]; int main() { long long n, k, maxx = -1, flag = 0; scanf("%lld %lld", &n, &k); for (long long i = 1; i <= n; i++) { scanf("%lld", &a[i]); if (a[i] > maxx) { maxx = a[i]; } } long long s = 1; for (long long i = 1; i <= 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
/** * DA-IICT * Author : PARTH PATEL */ import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class B879 { public static int mod = 1000000007; static 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
import sys def slist_to_int_list(l): return [int(x) for x in l] nbline = 0 for line in sys.stdin: if nbline == 0: ns,ks = line.split(" ") n = int(ns) k = int(ks) nbline +=1 else: order = slist_to_int_list(line.split(" ")) #print n,k #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
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; if (n < k) k = n + 3; vector<long> A(n); for (long i = 0; i < n; i++) { cin >> A[i]; } long score = 0; long champ = 0; long chal = 1; while (score < k) { if (champ == chal) { chal++; chal = ...
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 n, m, k, f, current; int flag, restart, flag2; priority_queue<int> pr; int main() { cin >> n >> m; f = m; queue<int> qu; cin >> flag; pr.push(flag); for (int i = 0; i < n - 1; i++) { cin >> k; qu.push(k); pr.push(k); } current = qu.fron...
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; void mejor(int player, long long int k, int *arr, int n) { if (player == 0) { if (player + k >= n - 1) cout << n << endl; else { for (int i = 0; i < k; i++) { if (arr[player] < arr[player + 1 + i]) { mejor(player + 1 + i, k, arr, 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
from collections import deque n , k = map(int , input().split()) l = [int(i) for i in input().split()] cont = 0 ; x = deque(l) ; j = l[0] ; x.popleft() x_init = x flag = 0 if(k > n-1): print(max(l)) exit() while(cont != k): if(j > x[0]): cont+=1 r = x.popleft() x.append(r) ...
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())) high = max(a.pop(0), a.pop(0)) try: if n == 2: raise IndexError while True: for i in range(k-1): if a[i] > high: high = a[i] a = a[i+1::] break elif i+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
n, k = [int(x) for x in input().split()] array = [int(x) for x in input().split()] count = 1 count1 = 0 previous_winner = -1 while count < k and count1 < n: winner = max(array[0], array[1]) loser = min(array[0], array[1]) if winner == previous_winner: count += 1 else: previous_winner = w...
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 d { static pair[] seg; static int[] a; public static void main(String args[]) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader sc = new InputReader(inputStream); 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
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class b{ public static void main(String[] args) { FastScanner in=new FastScanner(); int n=in.nextInt(); long k=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
n, needed = map(int, input().split()) players = list(map(int, input().split())) winner = players[0] wins = 0 for i in range(1, n): if players[i] > winner: winner = players[i] wins = 1 else: wins += 1 if wins >= needed: break 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()) a=[None]*n a = list(map(int, input().split())) c=0 while(c!=k): x=0 for i in range(1,n): if(a[0]>a[i]): x+=1 else: break if(x==k or x==n-1): c=k break else: if(a[0]>a[1]): t=a[1] a.pop(1) a.append(t) c+=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()) data = list(map(int,input().split())) if k>n-2: print(n) else: w=0 a=[0]*501 for j in range(1,n): if data[j]>data[w]: w=j a[w]+=1 if a[w]>=k: print(data[w]) break else: 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
class Solver: def run(self): n, k = map(int, input().split()) a = list(map(int, input().split())) if k < n: w = 0 j = 0 for i in range(1, n): if a[i] > a[j]: w = 1 j = i 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
n,k = map(int,input().split()) powers = list(map(int,input().split())) #print(powers) wins = [0]*(len(powers)+1) while True: if powers[0] > powers[1]: wins[powers[0]] += 1 t = powers[1] del powers[1] powers.append(t) else: wins[powers[1]] += 1 t = powers[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, raw_input().split()) a = map(int, raw_input().split()) if(n==2): print max(a) exit(0) ans = [] count = 0 for i in range(0,n): for j in range(i+1,2*n): if(a[j%n]<a[i]): count+=1 else: break ans.append(count) count = 1 if(k>n-2): print max(a) else: for i in range(len(ans)): if(ans[i]>...
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
line = input().split(" ") n = int(line[0]) k = int(line[1]) line = input().split(" ") powers = [int(line[i]) for i in range(n)] winner = 0 count = 0 if k > n - 2: winner = max(powers) else: while True: if powers[0] > powers[1]: count += 1 winner = powers[0] powers.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 main() { long long int n, k, count = 0, max = 0; cin >> n >> k; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; if (max < arr[i]) { max = arr[i]; } } while (count != k) { if (arr[0] == max) { break; } if (arr[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 = [int(i) for i in raw_input().split(' ')] powers = [int(i) for i in raw_input().split(' ')] if n - 1 <= k: print max(powers) exit() start = 0 i = 0 while start < k: current = powers[0] post = powers[1] p = min(current, post) powers.remove(p) powers.append(p) if current == 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; const long long oo = (1 << 30); int main() { long long n, k; cin >> n >> k; vector<long long> data(n); for (long long i = 0; i < n; i++) cin >> data[i]; if (k >= n - 1) { cout << n << '\n'; return 0; } long long cur1 = data[0]; long long cur2 = data[...
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 CF879B { public static void main(String[] args) { CF879B task = new CF879B(); Problem solver = task.new Problem(); Scanner in = new Scanner(System.in); int n = 0; long k = 0; int[] a = new int[0]; n = in.nextInt(); k = in.nextLong(); a = new 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
#include <bits/stdc++.h> using namespace std; int n; long long k; int arr[501]; int temp = -987654321; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) { scanf(" %d", &arr[i]); temp = max(temp, arr[i]); } if (k > n) { cout << temp << endl; return 0; } queue<pair<int, long long>> 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
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, k; cin >> n >> k; long long arr[n + 1]; for (long long i = 1; i <= n; i++) { cin >> arr[i]; } if (k >= n) { cout << (*max_element(arr + 1, arr + n + 1)) << endl; } 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
size, totalwins = [int(x) for x in input().split()] line = [int(x) for x in input().split()] players = list(line) champ = line.pop(0) wins = 0 for x in range(size-1): newbie = line.pop(0) if champ > newbie: wins += 1 else: champ = newbie wins = 1 if wins == totalwins: break if line: print(c...
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 import os import random import re import sys playerAndWins = input().split() noOfPlayers = int(playerAndWins[0]) noOfWins = int(playerAndWins[1]) playerPower = list(map(int, input().rstrip().split()[:noOfPlayers])) i=0 checker = [] if noOfWins > 1000: noOfWins = 1000 while len(checker) < noOfWins: ...
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()) t=list(map(int,input().split())) j=0 maxx=0 a=1 for i in t: if i>maxx: maxx=i h=1 if a==1: h=h-1 a=0 else: h+=1 if h==k: break print(maxx)
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; long long k; cin >> n >> k; long long tmp = k; vector<int> v; for (int i = 0; i < n; i++) { int x; cin >> x; v.push_back(x); } int mostRecentPower = v[0]; for (int i = 1; i < n; i++) { if (mostRecentPower > v[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
def main(): n, k = map(int, input().split()) p = list(map(int, input().split())) if k >= n: print(max(p)) else: for i in range(n): t = p[i] x = 1 if i == 0 else 0 if t == max(p[i:i+k+x]): print(t) return print(ma...
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 Mam { public static long geo(int q,int n ) { if (n==0 )return q; else { return (long) ( 1-Math.pow(q,n+1)/(1-q) )-1; } } public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n=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
#include <bits/stdc++.h> using namespace std; const int N = 505; int n; int arr[N]; int main() { long long int k; cin >> n >> k; k = min(k, 1LL * (n - 1)); for (int i = 1; i <= n; ++i) cin >> arr[i]; list<int> l; for (int i = 2; i <= n; ++i) l.push_back(arr[i]); int cur = arr[1]; int wins = 0; while (...
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 queue import Queue def find_winner(q, n, k): p1 = q.get() c = 0 while c < k: p2 = q.get() while c < k and p1 > p2: c += 1 q.put(p2) p2 = q.get() if c >= k: return p1 else: q.put(p1) p1 = p2 ...
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
pg = input().split() p = int(pg[0]) g = int(pg[1]) l = list(map(int, input().rstrip().split())) a = 0 count = 0 while count != g: a = int(l[0]) b = int(l[1]) if (count > p): if (a > b): count = g elif (a < b): a = b count = g else: if (a > b): 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, raw_input().strip().split(' ')) a = map(int, raw_input().strip().split(' ')) k1=[] x=0 w=0 x1=1 for i in range(1000): k1.append(0) if k>=(n): print max(a) else: while k not in k1: if a[0]>a[1]: fa=a[1] a.remove(a[1]) a.append(fa) k1[a[0]]=k1[a[0]]+1 elif a[1]>a[0]: fa=a[0] a.remo...
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.math.BigInteger; import java.util.Map.Entry; import static java.lang.Math.*; public class B extends PrintWriter { int solve(int n, long k, int[] a) { int w = 0, id = 0; for (int i = 1; w < k && i < n; i++, w++) { if (a[i] > a[id]) { ...
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; scanf("%d %d", &n, &k); int count = 0; queue<int> q; int i = 0, x, y; for (i = 0; i < n; i++) { scanf("%d", &x); q.push(x); } x = q.front(); q.pop(); while (count < k && count != n) { y = q.front(); q.pop(); 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
n, m=map(int, raw_input().split()) a=map(int, raw_input().split()) x=a[0]; k=0; t=0 if m<n: while x>=a[t]: if t<>0: a.append(a[t]) k+=1 if k==m: break if x<a[t+1]: x=a[t+1] k=0 a.append(x) t+=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
from collections import deque n, k = map(int, input().split()) if k > 5*n: k = 5*n a = deque(reversed(list(map(int, input().split())))) # print(a) cnt = 0 while True: if a[-1] < a[-2]: cnt = 1 a.appendleft(a.pop()) else: cnt += 1 x, y = a.pop(), a.pop() a.appendleft(y...
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 nums = input().split(' ') powers = input().split(' ') n = int(nums[0]) k = int(nums[1]) queue = [] for i in range(n): queue.append(int(powers[i])) ans = queue[0] s = 0 for j in range(1,n): if s >= k: #print(ans) break elif ans > queue[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
n,k=map(int,input().split()) l=list(map(int,input().split())) prev=l[0] c=0 if k>=(n-1): print(max(l)) else: while(c<k): if(l[0]>l[1] and prev==l[0]): lost=l.pop(1) c=c+1 l.append(lost) elif(l[0]<l[1] and prev==l[0]): prev=l[1] lost=l.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
import java.util.*; public class TableTennic { void solve() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long k = sc.nextLong(); long a[] = new long[n]; long p[] = new long[n]; for(int i=0;i<n;i++) a[i] = sc.nextLong(); long m = a[0],max = a[0]; int index = 0; boolean 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
# n = number of people # k = number of wins in a row # p = power of player n, k = map(int, input().split()) p = list(map(int, input().split())) current_player_power = p[0] current_player_wins = 0 for i in range(1, n): if p[i] < current_player_power: current_player_wins +=1 else: current_play...
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, a[505], cnt[505]; long long k; int main() { cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; int mx = a[0], mxi = 0; for (int i = 1; i < n; i++) { if (a[i] > mx) mxi = i, mx = a[i]; if (++cnt[mxi] == k) return cout << mx, 0; } cout << mx; }...
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(ii) for ii in raw_input().split(" ")] a=[int(ii) for ii in raw_input().split(" ")] if k>=n: print n #[i for i in range(n) if a[i]==n][0]+1 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[cha...
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()) b=[0]*501 a=list(map(int,input().split())) if k>=n-1: print(max(a)) exit() else: while max(b)!=k: if a[0]>a[1]: a.append(a[1]) del a[1] b[a[0]]+=1 else: a.append(a[0]) a[0]=a[1] del a[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.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
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
z,zz=input,lambda:list(map(int,z().split())) fast=lambda:stdin.readline().strip() zzz=lambda:[int(i) for i in fast().split()] szz,graph,mod,szzz=lambda:sorted(zz()),{},10**9+7,lambda:sorted(zzz()) from string import * from re import * from collections import * from queue import * from sys import * from collections impo...
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=[] b=[] for j in range(n): c.append(0) for s in a: b.append(s) if(k>=n): print(max(a)) else: wins=0 while(wins<k): if a[0]>a[1]: c[b.index(a[0])]=c[b.index(a[0])]+1 a.append(a[1]) a.remove(a[1]) else: c[b.index(...
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())) ans={} maxx=l[0] i=1 count=0 if(n<=k): print(max(l)) else: while(1): if(maxx>l[1]): ans[maxx]=ans.get(maxx,0)+1 if(ans[maxx]==k): print(maxx) break l.append(l.pop(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() { int n, i, count, j, temp; vector<int> arr; long long int k; scanf("%d %lld", &n, &k); for (i = 0; i < n; i++) { scanf("%d", &temp); arr.push_back(temp); } count = 0; if (k >= n) { for (i = 0; i < n; i++) { if (arr[i] > count) 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
#include <bits/stdc++.h> using namespace std; inline long long bigmod(long long p, long long e, long long M) { long long ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return ret; } inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '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
#include <bits/stdc++.h> using namespace std; vector<long long> win; queue<long long> q; signed main() { ios_base::sync_with_stdio(0); cout.precision(20); long long n, k; cin >> n >> k; for (long long i = 0; i < n; ++i) { long long pw; cin >> pw; win.push_back(pw); } for (long long i = 0; 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
#!/usr/bin/env python #-*- coding: utf-8 -*- from collections import defaultdict from math import factorial as f from fractions import gcd as g from collections import deque N, K = [int (i) for i in raw_input ().split ()] l = [int (i) for i in raw_input ().split ()] d = defaultdict (int) dq = deque () dq2 = deque () ...
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()) z = k a = list(map(int,input().split())) if(n-1<=k): print(max(a)) else: while(k>0): if(a[0]>a[1]): a[0],a[1]=a[1],a[0] l = a[0] a.pop(0) a.append(l) k-=1 else: l = a[0] a.pop(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; const int delta = (int)1e9 + 7; long long n, k, a[(int)1e3 + 20], ans, m[(int)1e3 + 20], x = 1, l = 1, r; int ac() { if (a[0] == m[k]) return a[0]; for (int i = 1; i + k - 1 < n; ++i) { if (a[i] == m[i + k - 1]) return a[i]; } return n; } int main() { ios_base...
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
# -*- coding:utf-8 -*- #[n, m] = [int(x) for x in raw_input().split()] def some_func(): """ """ n,k = [int(x) for x in raw_input().split()] n_list = [int(x) for x in raw_input().split()] i = 0 temp = n_list[i] cout = 0 while True: i+=1 if i==n: break ...
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
def pingpong(): n,k = map(int,input().split()) powers = list(map(int,input().split())) champ = powers[0] winCount = 0 for i in range(1,n): if powers[i] < champ: winCount += 1 else: champ = powers[i] winCount = 1 if winCount==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
a = list(map(int, input().rstrip().split())) player = list(map(int, input().rstrip().split())) win = 0 x = player.pop(0) def findWinner(x,player,win): if a[0]==2: if x > player[0]: return x else: return player[0] elif a[0] >= 20 and player == sorted(player): return player[len(player)-1] elif 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
min_wins = int(input().split(" ")[1]) players = input().split(" ") sitter = int(players[0]) players.pop(0) wins = 0 repeat_check = int(players[0]) while wins < min_wins: head = int(players[0]) if sitter > head: wins+=1 if wins == min_wins: print(sitter) quit() players.pop(0) players.a...
PYTHON3