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.awt.List; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.InputMismatchException; import java.util.Linked...
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()) b, c = 0, 0 for v in map(int, raw_input().split()): if b > 0: c = [1, c + 1][b > v] b = max(b, v) if c == k: break print b
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; cin >> n; long long k; cin >> k; if (n <= k) { cout << n << endl; } else { queue<int> q; for (int i = 0; i < n; i++) { int a; cin >> a; q.push(a); } int cur = q.front(), c = 0; q.pop(); while (c <...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, raw_input().split(' ')) power = map(int, raw_input().split(' ')) if k > n: print max(power) else: MaxSoFar = max(power[0], power[1]) OldMax = MaxSoFar counter = 1 for j in range(2,n): if MaxSoFar > power[j]: counter += 1 if counter == k: break else: MaxSoFar = power[j] counter =...
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
# table tennis from collections import deque def TableTennis(pw, power): wins = 0 power = deque(power) p1 = power.popleft() p2 = power[0] if len(power) == 1: if p1 > p2: print(p1) else: print(p2) else: while wins != pw[1]: if...
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()) x = list(map(int, input().split())) flag = 0 cnt = k while flag != n and cnt != 0: if x[0] > x[1]: x.append(x[1]) del x[1] cnt -= 1 flag += 1 elif x[0] < x[1]: x.append(x[0]) del x[0] cnt = k - 1 flag = 0 print(x[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 copy import copy from collections import deque in_1 = input().split() n = int(in_1[0]) k = int(in_1[1]) in_2 = input().split() current_player = int(in_2[0]) current_opponent = int(in_2[1]) enemy_q = deque() current_wins = 0 if n > 2: # Add all other enemies to the enemy queue (line) for i in in_2[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
#include <bits/stdc++.h> using namespace std; long long n, k; deque<int> ciag; int ileWygryw[501]; inline int symuluj() { while (true) { if (ciag[0] > ciag[1]) swap(ciag[0], ciag[1]); ciag.push_back(ciag.front()); ciag.pop_front(); ileWygryw[ciag.front()]++; for (int i = 0; i <= 500; 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.util.*; public class TestClass { public static void main(String args[] ) throws Exception { Scanner s1=new Scanner(System.in); int n=s1.nextInt(); long k=s1.nextLong(); if(n==2) { int n1=s1.nextInt(); int m=s1.nextInt(); if(n1...
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, b, k, n, w; int main() { cin >> n >> k >> a; for (int i = 1; i < n && a != n; ++i) { cin >> b; if (a < b) { a = b; w = 0; } ++w; if (w == k) { cout << a << endl; return 0; } } cout << n << endl; return 0...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#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()) l = list(map(int, input().split())) wi1 = 0 wi2 = 0 #print(l) if(k > n): print(max(l)) else: w = 0 while wi1 < k and wi2 < k: #print(l[0], l[1], l) if l[0] > l[1]: wi1 += 1 t = l[1] l.remove(l[1]) l.append(t) wi2 = 0 else: wi2 += 1 t = l[0] l.remove(l[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 queue n,k = map(int,input().split()) lista = list(map(int,input().split())) p1 = lista[0] p2 = lista[1] q = queue.Queue() for i in range(2,len(lista)): q.put(lista[i]) cnt = 0 while True: if p1 > p2: cnt+=1 q.put(p2) else: q.put(p1) p1 = p2 cnt = 1 p2 = q.get() if cnt == k or cnt >= n: print(...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Arrays; import java.util.Deque; import java.util.StringTok...
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
read = lambda: tuple(map(int, input().split())) def main(): n, k = read() l = list(read()) ps = {} def add(p): if not p in ps: ps[p] = 1 else: ps[p] += 1 return (ps[p] >= k, p) newl = [] while(len(l) > 1): v1, v2 = l[0], l[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
n,k=map(int,input().split()) a=list(map(int,input().split())) d,t=a[0],0 for i in range(1,n): if a[i]<d: t+=1 else: d=a[i] t=1 if t==k:break print(d)
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k=list(map(int,input().split())) a=list(map(int,input().split())) b=a[::-1] p=max(a) score=[0]+[0]*p from collections import * b=deque(b) while score[b[-1]]!=k and b[-1]!=p: x=b.pop() y=b.pop() b.appendleft(min(x,y)) b.append(max(x,y)) score[max(x,y)]+=1 print(b[-1])
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; long long n, k, xx, maxx, lastt = -1, recans; deque<long long> q; signed main() { scanf("%I64d%I64d", &n, &k); for (long long i = 1; i <= n; i++) { scanf("%d", &xx); q.push_back(xx); maxx = max(maxx, xx); } if (k > n) { printf("%I64d\n", maxx); r...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; import java.util.ArrayList; public class Main{ static class Pair{ int x; int y; Pair(){ } Pair(int x,int y){ this.x=x; this.y=y; } } public static void main(String[] args) { Scanner param = new Scanner(System...
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(lambda x: [int(x), 0], input().split())) while True: if a[0][0] > a[1][0]: tmp = a[1] a[0][1] += 1 a.remove(tmp) a.append(tmp) else: tmp = a[0] a[1][1] += 1 a.remove(tmp) a.append(tmp) if a[0][1] == k: break if a[0][1] > 10*n: break print(a[0][0])
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) powers = list(map(int, input().split())) power = powers[0] wins = 0 for i in range(1, n): if power > powers[i]: wins += 1 else: wins = 1 power = powers[i] if wins >= k: break print(power)
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); cin.tie(NULL); long long int n, k; cin >> n >> k; long long int a[n]; for (int i = 0; i < n; ++i) { cin >> a[i]; } long long int ans = a[0], cnt = 0; for (int i = 1; i < n; ++i) { if (a[i] < ans) ...
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 INF = 1e9; const int mod = 1e9 + 7; const int MX = 1e5 + 5; int main() { ios_base::sync_with_stdio(false); int n, scores[505]; long long k; list<int> a; memset(scores, 0, sizeof(scores)); cin >> n >> k; for (int i = 0; i < n; i++) { int val; ...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; /** * Created by Artem on 15.09.2017. */ public class Task { private String NAME = ""; private String ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE"); private BufferedReader in; private PrintWriter out; private StringTokenizer tok; public void init() t...
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()) p = list(map(int, input().split())) current = p[0] j = 0 for i in range(1,n): if p[i] < current: j += 1 else: current = p[i] j = 1 if j == k: break print(current)
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); ; long long i, j, k, t, n, x, cur, kount = 0; cin >> n >> k; vector<long long> vec; for (long long i = 0; i < n; i++) { cin >> x; vec.push_back(x); } cur = vec[0]; for (long long i = 0; i < n...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; long long n, k; long long arr[505]; vector<long long> v; int main() { scanf("%lld %lld", &n, &k); for (int x = 1; x <= n; x++) { scanf("%lld", &arr[x]); v.push_back(arr[x]); } if (k >= n) printf("%lld\n", n); else { long long idx = 0; 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
n,k = map(int,raw_input().split(' ')) l = map(int,raw_input().split(' ')) count = 0 winner = 0 done =0 for i in range(1,n): if(l[winner]<l[i]): winner = i count=1 else: count+=1 if count==k: done = 1 print l[winner] break if done ==0: k = max(l) 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 sys import stdin def sin(): return stdin.readline() n,k = map(int, sin().split()) p = list(map(int, sin().split(" "))) ans=0 for i in range(n): c=0 for j in range(i+1,n): if p[i]>p[j]: c+=1 else: break if i!=0 and p[i-1]<p[i]: c+=1 if c>=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
import re n, k = map(int, raw_input('').split(' ')) str = '' tab = [] str = raw_input('') tab = map(int, str.split(' ')) maks = max(tab) sila = tab[0] if sila == maks: print sila exit(0) ile_k = 0 for x in range(1, n, +1): if tab[x] == maks: print maks exit(0) if tab[x]<sila: ile...
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, k, m, i, r; vector<int> a; stack<int> s; cin >> n >> k; if (k >= n) cout << n; else { for (i = 0; i < n; i++) { cin >> r; a.push_back(r); } r = 0; m = 0; for (i = 0; i < n; i++) { if (s.empty()) ...
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()) person = list(map(int,input().split())) def winner(person,k): winning = 0 maxp = max(person) plaA = person.pop(0) plaB = person.pop(0) while winning < k: if plaA == maxp: break if plaA > plaB: winning +=1 person.appe...
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.lang.reflect.Array; import java.io.File; import java.io.*; import java.util.*; public class Main { // static final File ip = new File("input.txt"); // static final File op = new File("output.txt"); //...
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.*; public class Solution2 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); long k = scan.nextLong(); if(k >= n) { int max = 0; for (int i = 0; i < n; i++) { int x...
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.*; public class TableTennis { public static void main(String[] args) throws Exception { FastScanner sc = new FastScanner(System.in); PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); run(sc, out); out.close(); } public static voi...
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; bool cmp2(int a, int b) { return a > b; } int main() { int n; long long k; int ma = 0; list<int> l; cin >> n >> k; for (int i = 0; i < n; i++) { int a; cin >> a; l.push_back(a); ma = ma > a ? ma : a; } if (k > 500) { cout << ma; retur...
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 TabTen { public static void main(String[] args) { Scanner in = new Scanner(System.in); int a = in.nextInt(); long j = in.nextLong(); int b = in.nextInt(); long k = 0; for(int x = 1; x < a; x++) { int c = in.nextInt(); if(c > b) { k = 1; b = c; } else ...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; long long k; cin >> n >> k; int a, lar = 0, co = 0; cin >> a; lar = a; for (int i = 1; i < n; i++) { cin >> a; if (lar > a) { co++; } else { lar = a; co = 1; } if (co == k) { cout << lar; re...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
from sys import stdin,stdout n,k = map(int,stdin.readline().split()) p = list(map(int,stdin.readline().split())) if k >= (n-1): stdout.write(str(max(p))) else: n1 = p[0] del p[0] c = 0 for item in p: if item > n1: n1 = item c = 1 else: c = 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
a,b=map(int,input().split()) z=list(map(int,input().split())) r=z.index(max(z)) for i in range(r): s=0 if i!=0: if z[i-1]<z[i]:s+=1 for j in range(i+1,r): if z[i]>z[j]:s+=1 else:break if s>=b:exit(print(z[i])) print(max(z))
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 queue import Queue n, k = map(int, input().split()) a = list(map(int, input().split())) q = Queue() for i in a: q.put(i) if k > n: print(max(a)) else: best, pontos = q.get(), 0 while True: f = q.get() if best > f: pontos += 1 q.put(f) else: q.put(best) best, pontos = ...
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 pingpong(n, k): power = [int(i) for i in input().split()] wins = 0 for i in range(1, n): if wins >= k: return power[0] elif power[0] > power[i]: wins += 1 else: wins = 1 power[0] = power[i] return...
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; static const int MAXN = 1e3 + 10; int a[MAXN]; int main() { int n; long long k; scanf("%d%lld", &n, &k); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); } if (k > n) return printf("%d\n", *max_element(a + 1, a + 1 + n)) * 0; int now = a[1], cnt = 0; f...
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 B879 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner (System.in); Queue <Integer> q = new LinkedList <Integer>(); int n = in.nextInt(); long k = in.nextLong(); int wp; int p1,p2; long count; for(int i=0;i<n;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; int main() { int n; long long k; cin >> n >> k; queue<int> q; for (int i = 0; i < n; i++) { int x; cin >> x; q.push(x); } int a = q.front(); q.pop(); int b = q.front(); q.pop(); int curr = max(a, b); q.push(min(a, b)); int c = 1; whil...
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 def ping_pong(wins, players): p = deque(players) idx = 0 while idx < len(p): win_count = 0 has_fought = [] fight_count = 0 while True: fight_count += 1 # handles edge case if(p[0] > p[1]): if fight_count == 1 and p[0] > p[-1]: win_count += 2 else: wi...
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 - 1: print(n) else: if a[1] > a[0]: index = 1 max_value = a[1] else: index = 0 max_value = a[0] for i in range(2, k): if a[i] > max_value: max_value = a[i] 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
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; int cnt[505] = {0}; long long tem, mx = 0; queue<pair<long long, int> > q; for (int i = 1; i <= n; i++) { cin >> tem; q.push({tem, i}); mx = max(mx, tem); } pair<long long, int> x = q.front(); q.pop()...
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 double PI = acos(-1); long long power(long long a, long long b, long long m = 1000000007) { long long ans = 1; a = a % m; while (b > 0) { if (b & 1) ans = (1ll * a * ans) % m; b >>= 1; a = (1ll * a * a) % m; } return ans; } long long gcd(long 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
n, k = map(int, input().split()) a = list(map(int, input().split())) maxa = max(a) if len(a) <= k: print(maxa) else: qq = a[0] j = 0 for i in range(1, len(a)): if j == k: print(qq) 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
import java.util.Scanner; public class Tabletennis { public static int max(int a,int b){ return a>=b?a:b; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long nbwin = sc.nextLong(); int Players[] = new int[500]; for(int i=0;i<n;i++){ Pla...
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 pdb nk = map(int, raw_input().split()) n = nk[0] k = nk[1] players = map(int, raw_input().split()) winner = players[0] #pdb.set_trace() ############### if k >= n - 1: print max(players) else: wins = 0 while wins < k: if players[0] > players[1]: wins += 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
#include <bits/stdc++.h> using namespace std; int main() { int n; long long k; scanf("%d", &n); scanf("%I64d", &k); int a; scanf("%d", &a); int ans = a; int count = 0; if (k > n - 2) { for (int i = 1; i < n; ++i) { scanf("%d", &a); if (a > ans) ans = a; } } else { for (int 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 a, b, c, d, i, e, f, g, n, m, k, l, A[100005], maxx; map<int, int> mp; int main() { cin >> n >> k >> A[1]; maxx = A[1]; for (i = 2; i <= n; i++) { cin >> A[i]; maxx = max(maxx, A[i]); mp[maxx]++; if (mp[maxx] == k) { cout << maxx; ...
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 Code { public static void main(String[] args) { Scanner sc = new Scanner(System.in); short n = sc.nextShort(),s=0,a; long k=sc.nextLong(); short temp = sc.nextShort(); for(int i=1;i<n;i++){ a = sc.nextShort(); 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
l=lambda:map(int,raw_input().split()) n,k=l() a=l() maxi=a[0] c=0 for v in a[1:]: if maxi>v: c+=1 if c==k: break else: maxi=v c=1 print maxi
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()) powers = list(map(int,input().split())) max_power = powers[0] for a in powers: if max_power < a: max_power = a if n == 2 or k > n -2 or powers[0] == max_power: print(max_power) else: temp_max = 0 number_of_wins = 0 for a in powers: if a > temp_max:...
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[1001]; int main() { int n; long long k; int mx = 0; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> A[i]; mx = max(mx, A[i]); } int z1 = 1; int z2 = 2; long long p = 0; if (k >= n - 1) { cout << mx; return 0; } while (p < k...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
nk = input().split() p = input().split() playerCount = int(nk[0]) winsRequired = int(nk[1]) winnerWins = 0 newWinner = 0 currentWinner = 0 if int(playerCount) < int(winsRequired): currentWinner = playerCount winnerWins = winsRequired while winnerWins < winsRequired: newWinner = 0 if int(p[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; template <typename T> T gcd(T x, T y) { if (x < y) swap(x, y); while (y > 0) { T f = x % y; x = y; y = f; } return x; } template <typename T> pair<T, T> exgcd(T x, T y) { int sw = 0; if (x < y) sw = true, swap(x, y); pair<T, T> r = make_pair(1, 0);...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Collection; import java.util.Deque; import java.util.Iterator; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class Main { public static void main(String[]...
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.Arrays; import java.util.Scanner; public class B { static long[] och = new long[6000]; public static void main(String[] args) { Scanner in = new Scanner(System.in); Arrays.fill(och, 0); int n = in.nextInt(); long k = in.nextLong(); int[] a = new int[n + 2]; int ans_id = 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,k=map(int,input().split()) a=[int(i) for i in input().split()] if n==2: print(max(a)) exit() if k>n: print(max(a)) exit() k+=1 a=a+a a.insert(0,10**9) for i in range(1,n+1): if a[i]==max(a[i-1:i+k-1]) or a[i]==max(a[i:i+k]): print(a[i]) exit() print(max(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
n,k = list(map(int,input().split())) powers = list(map(int,input().split())) current_streak=0 if k>n-1: print(max(powers)) exit(0) while True: if powers[0]>powers[1]: current_streak+=1 temp = powers.pop(1) powers.append(temp) else: current_streak=1 temp = powers.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.*; import java.io.*; import java.math.*; public class mmm { static class InputReader { public BufferedReader br; public StringTokenizer token; public InputReader(InputStream stream) { br=new BufferedReader(new InputStreamReader(stream),32768); ...
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
nw = input().split() playersCount = int(nw[0]) victoriesNeeded = int(nw[1]) powP = list(map(int, input().rstrip().split())) if (playersCount < victoriesNeeded): print(max(powP)) else: win = 0 while win < victoriesNeeded: if int(powP[0]) > int(powP[1]): powP.append(powP.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.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 streak = 0; long winner = in.nextLong(); ...
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.*; /* TASK: CFB LANG: JAVA */ public class CFB { static int n; static long k; static int[] power; public static void main(String[] args) throws IOException { FastScanner in = new FastScanner(System.in); n = in.nextInt(); k = in.nextLong(); ...
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.LinkedList; import java.util.Scanner; public class p3 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); long k = scan.nextLong(); LinkedList<Integer> list = new LinkedList<Integer>(); long[] a = new long[501]; for (int i = 0; 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; int n, a[100010], mx; long long k; queue<int> q; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; if (mx < a[i]) mx = a[i]; } if (k >= n) cout << mx; else { int times = 0, winner = 1, fighter = 2, last = n; while (times <...
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 Tennis { public static void main (String[] args) { Scanner scan = new Scanner(System.in); int noPeople = scan.nextInt(); long noWins = scan.nextLong(); int p1 = scan.nextInt(); long tmp = 0; for (int i = 1; i < noPeople; i++) { int p2 = scan.nextIn...
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, raw_input().split()) a = map(int, raw_input().split()) q = Queue.Queue() if k >= n-1: print max(a) else: for i in range(1, n): q.put(a[i]) b, w = a[0], 0 while w < k: top = q.get() if b > top: q.put(top) w += 1 else: q.put(b) b, w = top, 1 print b ...
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()) l=list(map(int,input().split())) cnt=[0]*n queue=l[:] for i in range(n): a,b=queue[0],queue[1] m=max(a,b) mi=min(a,b) cnt[l.index(m)]+=1 queue.remove(mi) queue[0]==m queue.append(mi) if max(cnt)==k: print(l[cnt.index(max(cnt))]) quit() print(...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
(n, k) = [int(x) for x in input().split(' ')] a = [ int(x) for x in input().split(' ')] if k >= 10 * (n - 1): print(max(a)) else: winner = a.pop(0) conseq_win = 0 while conseq_win != k: u = winner v = a.pop(0) if u > v: a.append(v) conseq_win = conse...
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
pessoaVitoria = map(int,raw_input().split()) jogadas = map(int,raw_input().split()) numeroVitoria = pessoaVitoria[1] jogador = jogadas[0] A = 1 contVitoria = 0 jogadas.append('fim') while(True): if(contVitoria >= pessoaVitoria[1] or jogadas[A] == 'fim'): break else: if(jogador > jogadas[A]): contVitoria += 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
#include <bits/stdc++.h> using namespace std; int n; long long k; int main() { cin >> n >> k; int *a = new int[n + 1]; int *win = new int[n + 1]; int max_v = 0; int x; for (int i = 0; i < n; i++) { cin >> a[i]; win[i] = 0; max_v = max(max_v, a[i]); } if (k >= n) { cout << max_v; retu...
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 i, j, k, l, mx, n, a[505], cnt[505]; int main() { cin >> n >> k; for (i = 1; i <= n; i++) { cin >> a[i]; mx = max(mx, a[i]); } i = 1, j = 2; while (i < n) { while (a[i] > a[j]) { cnt[a[i]]++; if (cnt[a[i]] == k) { cout << ...
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())) t=a[0] c=0 i=1 while i<len(a): if t>a[i]: a.append(a[i]) c+=1 else: c=1 a.append(t) t=a[i] if c>=k: print(t) break if i>2*(n-1): print(max(a)) break i+=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
R=list(map(int,input().split())) n=R[0] k=R[1] a=list(map(int,input().split())) 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
import queue import sys n, k = map(int, input().split()) ar = list(map(int, input().split())) if n == 2: print(2) sys.exit(0) q = queue.Queue() maxi = max(ar) for i in ar: q.put(i) wins = 0 a = q.get() if a == maxi: print(a) sys.exit(0) while True: b = q.get() if b == maxi: print(b) sys.exit(0) if b > ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.Deque; import java.util.LinkedList; import java.util.Scanner; public class B879 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); long K = in.nextLong(); if (K > N-2) { System.out.println(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
a = input().split() b = input().split() players = [int(i) for i in b] n = int(a[0]) k = int(a[1]) winA = 0 while True: if players[0] > players[1]: winA += 1 players.append(players.pop(1)) elif players[1] > players[0]: winA = 1 players.append(players.pop(0)) if winA == k or...
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 -*- def main(): n, k = map(int, input().split()) x = [int(x) for x in input().split()] if (k >= n): print(max(x)) return else: for i in range(0,n): if ((i+k)<n): if(i==0): temp = max(x[i:i+k+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() { long long int n, k, c = 0, m, p, q; cin >> n >> k; long long int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 2) { if (a[0] > a[1]) cout << a[0] << endl; else cout << a[1] << endl; } else { for (int i = 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
#http://codeforces.com/problemset/problem/879/B #solved n, k = list(map(int, input().split())) array = list(map(int, input().split())) atak = 0 bb = array[0] if max(array) < k: print(max(array)) quit() else: for i in range(n - 1): if bb < array[i + 1]: bb = array[i + 1] at...
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())) a=arr[0] b=arr[1] arr.pop(0) arr.pop(0) sumi=0 if(a>b): arr.append(b) maxp=a sumi+=1 else: arr.append(a) sumi+=1 maxp=b while(1): if(sumi==n-1 or sumi==k): print(maxp) break; if(max(maxp,arr[0])==maxp...
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 io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n, k = map(int, input().split()) a = list(map(int, input().split())) t = a[0] temp = 0 if k >= n-1: print(max(a)) else: while temp != k: x, y = a[0], a[1] if x > y: a.append(y) del a[1] else: a.append(x) del a[0] if 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
n, k = map(int, input().split()) a, i, v, c = list(map(int, input().split())), 0, 0, 0 while v < n and c < k: w, l = max(a[i], a[i + 1]), min(a[i], a[i + 1]) a[i + 1] = w a.append(l) c = c + 1 if w == v else 1 v = w i += 1 print(v)
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, a[5006]; while (cin >> n >> k) { for (int i = 1; i <= n; i++) cin >> a[i]; long long int mx = 0; map<int, int> mp; mx = a[1]; for (int i = 2; i <= n; i++) { mx = max(mx, a[i]); mp[mx]++; if (mp[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
from queue import deque n, k = map(int, input().split()) m, *l = map(int, input().split()) q, c = deque(l), 0 while m < n: a = q.popleft() if m < a: q.append(m) m, c = a, 1 else: q.append(a) c += 1 if c == k: break print(m)
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()) powers = map(int, raw_input().split()) winner = powers[0] wins = 0 index = 1 while (wins < k and len(powers) > index): if (powers[index] > winner): winner = powers[index] wins = 1 else: wins += 1 index += 1 print(winner)
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.ArrayDeque; import java.util.Scanner; public class Patient { public static void main(String[] args) { // TODO code application logic here Scanner sc=new Scanner(System.in); int n=sc.nextInt(); long k=sc.nextLong(); int count=0; int[] arr=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
import java.util.*; import java.math.*; import static java.lang.System.out; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); ArrayDeque<Integer> line = new ArrayDeque<>(); int n = cin.nextInt(); long k = cin.nextLong(); for (int i = 0; i < n; i++) { li...
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 P = 1e9 + 7; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long qpow(long long a, long long n) { long long r = 1 % P; for (a %= P; n; a = a * a % P, n >>= 1) if (n & 1) r = r * a % P; return r; } void exgcd(long long a, l...
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
##a = list(map(int, input().split())) ##print(' '.join(map(str, res))) [n, k] = list(map(int, input().split())) a = list(map(int, input().split())) wins = [0 for i in range(n+1)] if k < 1000: while True: x = a[0] y = a[1] if x > y: a.remove(y) a.append(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
n, k = map(int, input().split()) A = list(map(int, input().split())) if k == n - 1: ans = max(A) else: ans = A[0] cnt = 0 for i in range(1, n): if ans > A[i]: cnt += 1 if cnt == k: break else: ans = A[i] cnt = 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,k = list(map(int, input().split())) if k > n: print(n) else: cwinner, wins = (0, 0) a = list(map(int, input().split())) while wins < k: if a[0] > a[1]: a[1:] = a[2:] + [a[1]] if cwinner == a[0]: wins += 1 else: cwinner = 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
inputParameter = input() inputArrayContentFinal = [int(x) for x in input().split()] counter = 0 anothercounter = 0 inputParameterFinal = inputParameter.split(" ") arrayLength = inputParameterFinal[0] gamesToWin = int(inputParameterFinal[1]) while counter < gamesToWin: if len(inputArrayContentFinal) == 1: prin...
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
number_of_players, win_requirement = input().split() number_of_players = int(number_of_players) win_requirement = int(win_requirement) powers = input().split(' ') powers = [int(power) for power in powers] if powers[0] > max(powers[1:min(number_of_players, win_requirement + 1)]): print(powers[0]) else: powers = po...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; int fg = 0, a[505]; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; if (k >= n) cout << n << endl; else { for (int i = 0; i < n; i++) { int s = 0; if (i != 0 && a[i] > a[i - 1]) s = 1; for (int j = 1...
CPP