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.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n; double k; n = sc.nextInt(); k = sc.nextDouble(); sc.nextLine(); int tab[] = new int[n]; 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
n,k = map(int,input().split()) powers = [int(i) for i in input().split()] wins = {} for i in powers: wins[i]=0 i=0 while(True): if powers[0] == max(powers): print(powers[0]) break if powers[0] > powers[1]: wins[powers[0]]+=1 powers.append(powers[1]) powers.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; const int N = 510; int b[N]; int main() { int n, k; cin >> n >> k; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } if (k >= n) { cout << n; return 0; } int y = a[0]; for (int i = 1; i < n; i++) { int p = a[i]; if (p > y) { ...
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 main() { int i, n, t; vector<int> vi; map<int, int> mp; scanf("%d%lld", &n, &k); for (i = 0; i < n; i++) { scanf("%d", &t); vi.push_back(t); } while (1) { if (vi[0] > vi[1]) { mp[vi[0]]++; if (mp[vi[0]] >= 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
inp = list(map(int, input().split())) players = list(map(int, input().split())) n = inp[0] k = inp[1] if (n == 2): print(max(players[0], players[1])) else: flag = False indice_prox = 2 maior = max(players) num_vitorias = 0 prev_vencedor = max(players[0], players[1]) num_vitorias += 1 ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(),s=0,a=0,b=0,c=0,d=0,m; long x=sc.nextLong(); if(x>500)s=500; else s=(int)x; while(n-->0){ m=sc.nextInt(); ...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.LinkedList; import java.util.Scanner; /** * @author Jaseem */ public class TableTennis { long k; LinkedList<Integer> a; int solve(){ if(a.size()==1) return a.getFirst(); int champion=a.poll(); int winCount=0; while (winCount<k && winCount<a.size()){ ...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; const long N = 10000 + 10; long long n, k; int a[N]; int main() { cin >> n >> k; int boss = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; boss = max(a[i], boss); } int cur = a[1], curi = 1, curk = 0; if (a[1] == boss) { cout << boss; return 0; ...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k = map(int,input().split()) arr = list(map(int,input().split())) count = 0 i = 1 t = arr[0] while i<n: if arr[0]>arr[1]: arr.append(arr[1]) del arr[1] count += 1 else: arr.append(arr[0]) del arr[0] count = 1 if count==k: print(arr[0]) break ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k = map(int,input().split()) l = list(map(int,input().split())) my_max = l[0] count = 0 if(k>=n-1): print(max(l)) else: for i in l[1:]: if(my_max == max(my_max,i)): count += 1 else: count = 1 my_max = max(my_max, i) if (count == k): exit(...
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
I = lambda : map(int, input().split()) n, k = I() l = list(I()) if(n <= k): print(max(l[:k+1])) else: victories = 1 if(l[0] > l[1]): v = 0 else: v = 1 for i in range(2, len(l)): if(l[i] > l[v]): v = i victories = 1 else: victories ...
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 pw = input().split() p = int(pw[0]) w = int(pw[1]) powers = list(map(int, input().rstrip().split()[:p])) x = 0 checker = [] if w > 1000: w = 1000 #checker.append(powers[0]) while len(checker) < w: if powers[x] > powers[x+1]: checker.append(powers[x+1]) 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
n, k = map(int, input().split()) array = list(map(int, input().split())) winner = array[0] count = 0 for i in range(1, len(array)): if array[i] > winner: winner = array[i] count = 1 elif array[i] < winner: count += 1 if count == k: 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
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, now = 0; long long ma = 0, t, ch; queue<long long> Q; scanf("%lld %lld", &a, &b); for (int i = 0; i < a; i++) { scanf("%lld", &t); Q.push(t); if (ma < t) ma = t; } ch = Q.front(); Q.pop(); for (int i = 0; i <= a + 5...
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.ArrayDeque; import java.util.Arrays; import java.util.LinkedList; import java.util.StringTokenizer; public class Solution { public static void main(String[] args){ MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); ...
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
bruhMoment = input().split() n = int(bruhMoment[0]) k = int(bruhMoment[-1]) bruhMomentX = input().split() winCounter = 0 for i in range(1,n): if int(bruhMomentX[0]) > int(bruhMomentX[i]): winCounter += 1 else: bruhMomentX[0], bruhMomentX[i] = bruhMomentX[i], bruhMomentX[0] winCounter...
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 from collections import defaultdict n,k=list(map(int,input().split())) a=list(map(int,input().split())) maxo=max(a) if a.index(maxo)==0: print(maxo) elif n==2: print(maxo) elif k>n: print(maxo) elif k<=n: di=defaultdict(int) ans=0 que=a while True: ...
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()) cont = 0 player = powers[0] for i in range(1,len(powers)): if cont == k: break if player > powers[i]: cont += 1 else: player = powers[i] cont = 1 print player
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> int main(void) { long long int k; int n, pow1, cont = 0, pow2; scanf("%d %lli\n", &n, &k); scanf("%d", &pow1); for (int i = 1; i < n; i++) { scanf("%d", &pow2); if (pow1 < pow2) { pow1 = pow2; cont = 1; } else cont++; if (cont >= k) break; } print...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int,input().split()) powers = list(map(int,input().split())) win = 0 champ = powers[0] i = 1 while(i < len(powers)): if(win == k): break prox = powers[i] if(champ > prox): win += 1 else: champ = prox win = 1 i+=1 print(champ)
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()] it = iter(a) curr = -1 cnt = k x, y = next(it), next(it) while cnt > 0: nxt = max(x, y) if nxt > curr: cnt = k curr = nxt cnt -= 1 try: x, y = curr, next(it) except StopIteration: break pri...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
# -*- coding: utf-8 -*- import sys def f(n, k, fo): c = 0 p = 0 w = 0 if k >= n-1: p = max(fo) else: while c < k: if fo[1] > fo[0]: c = 1 p = fo[1] w = 0 else: c += 1 p = fo[0] w = 1 fo.append(fo.pop(w)) print(p) 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=int(input()) # n,k=map(int,input().split()) # arr=list(map(int,input().split())) #ls=list(map(int,input().split())) #for i in range(m): # for _ in range(int(input())): #from collections import Counter #from fractions import Fraction #s=iter(input()) from collections import deque n,k=map(int,input().split()) arr=lis...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; import java.util.TreeSet; import java.lang.*; public class abc{ public static void main(String args[]){ Scanner in=new Scanner(System.in); int i,n=in.nextInt(); String z=in.next(); int l=z.length(); int k; if(l>3) k=1000; else k=Integer.parseInt(z); int maxw...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, maxx = -1, a, b, prev, curr, counter, i, x; cin >> n >> k; deque<int> dq; for (i = 0; i < n; i++) { cin >> x; maxx = max(x, maxx); dq.push_back(x); } if (k > n) cout << maxx << endl; else { counter = 1; a = ...
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::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; long long k; cin >> n >> k; deque<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (k <= n) { long long w = 0; int c = a[0]; a.pop_front(); while (w !...
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())) per = A[0] cons =0 ans =0 for j in range(1,n): if (per > A[j]): cons+=1 if cons == k: print(per) ans = 1 break else: cons = 1 per = A[j] if(ans==0): print(per)
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 tabletennis{ public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int people = Integer.parseInt(st.nextToken()); ...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } if (k >= n - 1) { int ans = INT_MIN; for (int i = 0; i < n; i++) { ans = max(ans, arr[i]); } cout << ans << endl; } else { dequ...
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
p=input().rstrip().split(' ') q=input().rstrip().split(' ') if int(p[1])>=len(q): q.sort(key=int,reverse=True) print(int(q[0])) else: i=0; K=0; D=0; while(1): if K<int(p[1]) and D<int(p[1]): if int(q[i]) > int(q[i+1]): if D==0: 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() { ios::sync_with_stdio(0); cin.tie(0); long long n, k; cin >> n >> k; queue<int> q; for (int i = 0; i < n; i++) { int x; cin >> x; q.push(x); } int tmp = q.front(), c = 0; q.pop(); while (true) { if (tmp == n) { cout << 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 sys import stdin, stdout n, k = map(int, stdin.readline().split()) values = list(map(int, stdin.readline().split())) if k >= n - 1: stdout.write(str(max(values))) else: for i in range(n): if values[i] == max(values): stdout.write(str(max(values))) break 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
n, k = map(int, input().split()) a = list(map(int, input().split())) if k >= n: print(max(a)) else: a = a + a q = 0 pre = a[0] ind = 0 for i in range(1, n * 2): if pre > a[i]: q += 1 if q >= k: print(pre) exit() 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
from collections import deque n, k = map(int, raw_input().split()) a = map(int, raw_input().split()) if (k > n): print max(a) else: q = deque(a) b = q.popleft() w = 0 while True: top = q.popleft() if b > top: q.append(top) w += 1 else: q....
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.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { static BufferedReader br; static StringTokenizer sc; static PrintWriter out; public static void main(St...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
from collections import deque, defaultdict power_map = defaultdict(lambda: 0) n, k = map(int, input().split(' ')) ai = list(map(int, input().split(' '))) if k > n: print(max(ai)) else: a = deque(ai) win = 0 while True: win = max(a[0], a[1]) loose = min(a[0], a[1]) a.remove(lo...
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.ArrayDeque; import java.util.StringTokenizer; public class test{ public static class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner() { br = new Buffere...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) a=list(map(int,input().split())) if k>=n: print(max(a)) else: if a[0]<a[1]: a[0],a[1]=a[1],a[0] m=0;pw=a[0];temp=0 while m!=k: if a[1]<=pw: temp=a[1];del a[1] a.append(temp);m+=1 else: m=1;pw=a[1] temp=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
def tabletennis(pl, w): i = 0 p1 = pl[0] p2 = pl[1] if p1 > p2: r = pl.pop(1) pl.append(r) else: p1 = p2 r = pl.pop(0) pl.append(r) i += 1 while i != w: if p1 > pl[1]: i += 1 pl.append(pl[1]) pl.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; long long k; cin >> n >> k; int *power = (int *)malloc(sizeof(int) * n); for (int i = 0; i < n; i++) { cin >> power[i]; } int winner = max(power[0], power[1]); int num_wins = 1; for (int i = 2; i < n; i++) { if (power[i] > winne...
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 find_winner(powers_array, required_number_of_straight_wins): if required_number_of_straight_wins > len(powers_array): required_number_of_straight_wins = len(powers_array) powers_queue = deque(powers_array) number_of_straight_wins = 0 current_winning_power = powers_queue.po...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) a=list(map(int,input().split())) z=0 c=0 b=0 x=0 t=a[0] m=0 while b+k < n: if b==0: b==1 if m==1: u=k else: u=k+1 for i in range(b,b+u): z=0 if t < a[i]: t=a[i] b=i z=1 m=1 br...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
def simulate(k, l): #format per item: [power, location, no of wins] l = [[l[i], i, 0] for i in range(len(l))] curr = l.pop(0) while True: opp = l.pop(0) if curr[0] > opp[0]: l.append(opp) curr[2] += 1 else: l.append(curr) curr = [i for i in opp] curr[2] += 1 if curr[2] >= k: return curr[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
s = (input().split()) n = int(s[0]) k = int(s[1]) a = [int(i) for i in input().split()] powerfull = a[0] key = 0 if k > n : print(max(a)) else : while (key<k) : if(a[0] > a[1]) : key+=1 for i in range(1,n-1): a[i],a[i+1] = a[i+1],a[i] if (a[0] < a[1] and k!=ke...
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.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class ProblemB { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; import java.io.*; import java.text.*; public class t{ static final long mod = (long)1e8, root = 23; static long IINF = (long)1e18+1; static int MAX = (int)1e6+1, B = 10; static FastReader in; public static void main(String[] args) throws Exception{ in = new FastReade...
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()) ar = map(int, raw_input().split()) if(k >= n): print max(ar) else: ar += ar for l in xrange(n): true = True for j in xrange(l+1, k+l + 1): if ar[l] < ar[j ]: true = False break if l == 0: k -=1 if true: print ar[l] exit()
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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and 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[1000], mx; int main() { long long n, k; cin >> n >> k; if (k >= n) { cout << n; return 0; } long long cnt = 0; for (int i = 1; i <= n; ++i) { cin >> a[i]; if (cnt >= k) break; if (mx > a[i]) cnt++; else { cnt = 0; ...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; public class TT { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); short n = sc.nextShort(); long k = sc.nextLong(); short a[] = new short[n - 1]; short x = 0; int y = 0; for(short i = 0; i < n; i++) { if(i == 0) 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 queue q=queue.Queue() t1=input() t1=t1.split(' ') pNum=int(t1[0]) lNum=int(t1[1]) t2=input() t2=t2.split(' ') maxf=0 maxn=0 i=0 l=len(t2) while i<l: t2[i]=int(t2[i]) q.put(t2[i]) if(maxf<t2[i]): maxf=t2[i] maxn=i i+=1 #print(str(maxf)+' '+str(maxn)) tadd=0 gq=0 p=0 tm=0 tm=q.get...
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())) m=max(l) count=0 p=l[0] i=1 flag=0 if n==2: if p>l[1]: print(p) else: print(l[1]) else: while(count!=k ): if i==n: p=m flag=1 break if(p>l[i]): count=count+1 l.append(l[i]) else: count=1 l.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() { int n, p, p1, p2, flag, z; long long k, c1 = 0, c2 = 0; cin >> n >> k; if (k > n) z = n; else z = k; list<int> powers; for (int i = 0; i < n; ++i) { cin >> p; powers.push_back(p); } p1 = powers.front(); powers.pop_front(); ...
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.*; public class Main { private static String s = ""; private static int max = 0; public static void main(String[] args) throws IOException { FastReader f = new FastReader(); int n = f.nextInt(); long k = f.nextLong(); int[] arr = new 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
def main(): n,k = map(int,input().split()) tabT = list(map(int,input().split())) if k > n: print(max(tabT)) else: won = [0]*n q = [x for x in range(n)] while won[q[0]] < k: t1 = tabT[q[0]] t2 = tabT[q[1]] if t1 > t2: won[q[0]] += 1 q.append(q.pop(1)) else: won[q[1]] += 1 q.app...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
from collections import deque playerCount, playerWins = [int(i) for i in input().strip().split()] playerPower = [int(i) for i in input().strip().split()] pP = deque() breakLoop = False for i in range(playerCount): pP.append(playerPower[i]) pPdict = {i:0 for i in pP} if playerCount == 1: print(pP[0]) elif 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
cin=lambda:list(map(int,input().split())) n,k=cin() A=cin() C=[0 for i in range(n+1)] while True: 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 java.io.*; import java.util.*; import java.util.regex.*; public class vk18 { public static void main(String[]stp) throws Exception { Scanner scan=new Scanner(System.in); //BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //String []s; int n=scan.nextI...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
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() if(k > n-1): print(max(l)) exit() while(cont != k): if(j > x[0]): cont+=1 r = x.popleft() x.append(r) else: cont = 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 = list(map(int,input().split())) p = list(map(int,input().split())) tested = p[0] wins = 0 for i in range(1, n): if p[i] < tested: wins+=1 else: wins=1 tested = p[i] if wins == k: break print(tested)
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
nk = input().split() n = int(nk[0]) k = int(nk[1]) powers = input().split() wins = {} visit = {} winner = 0 maxPower = 0 for i in range(len(powers)): wins[int(powers[i])] = 0 visit[int(powers[i])] = False winnerNode = int(powers.pop(0)) visit[winnerNode] = True while(True): p1 = int(powers.pop(0)) if(visit[p1] ==...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
linea1 = [int(x) for x in input().split()] lista = [int(x) for x in input().split()] total = linea1[0] minimo = linea1[1] #maximo = 0 ganador = 0 contador = 1 if lista[0]>lista[1]: #maximo = lista[0] #c = lista[1] ganador = lista[0] lista.remove(lista[1]) #lista.append(c) else: c = lista[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.ArrayDeque; import java.util.Deque; import java.util.Scanner; public class Main { static Scanner in = new Scanner(System.in); void solve() { int n = in.nextInt(); long k = in.nextLong(); Deque<P> q = new ArrayDeque<>(); 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
//package org.anurag.ds; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; public class Problem_879_B { public static void main(String[] args) throws IOException { Map<Integer, Long> map = ...
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
first = input().split() second = input().split() intFirst = [] for x in first: intFirst.append(int(x)) intSecond = [] for y in second: intSecond.append(int(y)) numberPlayers = intFirst[0] wins = intFirst[1] counter = 0 winner = 0 realWinner = 0 if numberPlayers < wins: print(max(intSecond)) 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()) l=list(map(int,input().split())) if(n<=k): l.sort() l.reverse() print(l[0]) else: t=0 while(t<k): if(l[0]>l[1]): x=l[1] l.remove(l[1]) l.append(x) t+=1 elif(l[1]>l[0]): x=l[0] l.remo...
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
line1 = [int(i) for i in input().split()] n = line1[0] k = line1[1] players = input().split() mapa = {} maior = 0 result = 0 while(maior < k): greater = players[0] minor = players[1] if(int(players[1]) > int(greater)): greater = players[1] minor = players[0] if(len(players) == 2): ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; public class B { static StringBuilder st = new StringBuilder(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); long k = sc.nextLong(); Queue<Integer...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) l=list(map(int,input().split())) class Queue: def __init__(self): self.items=[] def enqueue(self,item): self.items.append(item) def insrt(self,item): self.items.insert(0,item) def dequeue(self): return self.items.pop(0) def is_empty(self):...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) v = list(map(int, input().split())) occ = 0 pre = v[0] for i in range(1, n): if pre>v[i]: occ+=1 else: pre = v[i] occ = 1 if occ==k: break print(pre)
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
mod = 1000000007 ii = lambda : int(input()) si = lambda : input() dgl = lambda : list(map(int, input())) f = lambda : map(int, input().split()) il = lambda : list(map(int, input().split())) ls = lambda : list(input()) n,k=f() l=il() wn=-1 im=l.index(max(l)) if k>=im: print(max(l)) else: mx=max(l[0],l[1]) 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 Queue nk = raw_input().split() n = int(nk[0]) k = int(nk[1]) lis = raw_input().split() # # stack = [] # q = Queue.Queue() # for i in range(0,n): # # stack.insert(0,int(lis[i])) # q.put(int(lis[i])) # p1 = q.get() # p2 = q.get() # winner = 0 # if p1>p2: # winner = p1 # q.put(p2) # else: # winner = p2 # ...
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
#!/usr/bin/env python3 from collections import deque def simu(k,A): M = max(A) v = 0 while A[0]<M and v<k: if A[0]>A[1]: v += 1 A.append(A[1]) A[1] = A[0] else: v = 1 A.append(A[0]) A.popleft() return A[0] def main():...
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.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayDeque; import java.util.Arrays; import java.util.InputMismatchException; import java.util.LinkedList; import java.util.Queue; //package acm_practice; /** * * @author ghost */ publi...
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; using ll = long long; int main() { ios::sync_with_stdio(0), cin.tie(0); int n; ll k; cin >> n >> k; vector<int> a(n); for (int &i : a) cin >> i; int c = 0; while (a[0] != n && c < k) if (a[0] > a[1]) { int d = a[1]; a.erase(begin(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
import Queue q = Queue.Queue() n,k = map(int,raw_input().split()) a = map(int,raw_input().split()) if (k>n): print max(a) else: for i in a: q.put(i) tam = q.qsize() i = a[0] w = 0 q.get() #cont = 0 #while cont < tam: while True: top = q.get() if i > top: s = q.put(top) w += 1 else: s = q.put(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
n, k = map(int, input().split()) a = list(map(int, input().split())) if n == 2: print(max(a)) elif n - 1 <= k: print(max(a)) else: f = a.pop(0) s = a.pop(0) if f > s: curr = f a.append(s) else: curr = s a.append(f) f = s row = 1 while row != 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 java.util.*; //Mann Shah [ DAIICT ]. public class Main { public static void main(String[] Args) { Scanner in = new Scanner(System.in); int mod = 1000000007; int n = in.nextInt(); long k = in.nextLong(); int[] a = new int[n]; int max=0; for(int i=0;i<n;i++) { a[i]=in.nextInt(); if...
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.lang.*; import java.math.*; import java.io.*; /* N1k5 De5@1 */ public class codeforces implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFilter fi...
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; template <typename T> using V = vector<T>; int main() { ios::sync_with_stdio(0); cin.tie(0); int64_t N, K; cin >> N >> K; V<int> A(N); for (auto &e : A) { cin >> e; }; int m = *max_element(begin(A), end(A)); queue<int> Q; for (int 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
#include <bits/stdc++.h> using namespace std; void priyanshu() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { priyanshu(); long long n, k; cin >> n >> k; long long a[n], maxm = 0; for (long long i = 0; i < n; i++) { cin >> a[i]; maxm = max(maxm, a[i]); } long long j ...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; import java.lang.*; import java.io.*; public class Solution { public static void main(String[] args) { InputReader fi = new InputReader(System.in); int n,m,i,j; n=fi.nextInt(); long k=fi.nextLong(); long wins,p1,p2; LinkedList<Long> al=new 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
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
n, k = map(int, input().split()) a = [int(x) for x in input().split()] p = a[0] c = 0 for i in range(1, n): if p == n: print(p) break if p > a[i]: c += 1 if c == k: print(p) break else: p = a[i] c = 1 if p == n: 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
#include <bits/stdc++.h> using namespace std; int main() { int n; long long k; cin >> n >> k; deque<int> Q; for (int i = 0; i < n; i++) { int power; cin >> power; Q.push_back(power); } int absoluteWinner = 0; int lastWinner = 0; int winsInARow; for (int i = 0; i < n - 2; i++) { int A...
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,b=map(int,input().split()) l=list(map(int,input().split())) s=0 pre=l[0] for i in range(1,a): if pre>l[i]: s+=1 else: pre=l[i] s=1 if s==b: break print(pre)
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));j=0 for i in range(r): s=0 if i<j:continue 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
n,k = map(int,input().split()) po = list(map(int,input().split())) if k>=len(po): print(max(po)) else: wins=0 q=po[:] while(wins!=k): cp = q.pop(0) while True: i = q[0] if i<cp: wins+=1 q.append(q.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
def solve(): from collections import deque n, k = map(int, raw_input().split()) arr = map(int, raw_input().split()) mmax = max(arr) arr = deque((i, 0) for i in arr) while True: p1 = arr.popleft() p2 = arr.popleft() if p1[0] == mmax: return mmax ...
PYTHON
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k= map(int,input().split()) a= list(map(int,input().split())) 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
nk = input().split() n = int(nk[0]) k = int(nk[1]) a = list(map(int, input().rstrip().split())) index = k count = 0 while index>0: if a[0]>a[1]: a.append(a[1]) a.pop(1) else: a.append(a[0]) a.pop(0) index = k index-=1 count +=1 if count==(n-1): 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
# python3 # utf-8 players_nr, max_win_streak = (int(x) for x in input().split()) player_idx___power = [int(x) for x in input().split()] if max_win_streak > players_nr: print(max(player_idx___power)) quit() curr_win_streak = 0 curr_power = player_idx___power[0] next_player_idx = 1 while curr_win_streak < max_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
#include <bits/stdc++.h> using namespace std; char c1[100005]; vector<int> v; string s = ""; long long res = 0; int main() { unsigned long long n, k, mx, i(0), d; cin >> n >> k; n--; cin >> d; mx = d; while (n--) { cin >> d; if (mx > d) { i++; if (i == k) { cout << mx; 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
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.BigInteger; import java.util.regex.*; public class Myclass { public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter pw = new PrintWriter(System.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
import java.util.*; public class Main { public static void main(String args[]){ Scanner reader=new Scanner(System.in); int a=reader.nextInt(); long b=reader.nextLong(); ArrayList<Integer> l=new ArrayList<Integer>(); int max=0; for(int n=0;n<a;n++){ int num=reader.nextInt(); if(num>max){ max=num...
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.text.*; import java.math.*; import java.util.regex.*; public class TryB { static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; public InputReader(InputStream st)...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
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(); ArrayList<Integer> arr = new ArrayList<>(); for (int i = 0; i < n; i++) { arr.add(sc.nextInt()); ...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.Scanner; public class TableTennis { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long k = sc.nextLong(); int arr[] = new int[n]; int max = 0; int c = 0; int ans = 0; ...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
from collections import deque 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 if(p[0] > p[1]): if fight_count == 1 and p[0] > p[-1]: win_count += 2 else: win_count += 1 has...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; public class Main { static BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out)); static StringBuilder ans = new StringBuilder(); static String line; st...
JAVA