prompt
string
response
string
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int n, i, j, a[505], mx = 0, f[1000005], head, tail, t; long long k; int main() { cin >> n >> k; for (i = 1; i <= n; i++) { scanf("%d", &a[i]); mx = max(mx, a[i]); f[i] = a[i]; } if (k > n) { cout << mx; return 0; } t = 0; head = 1; tail ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; long long cnt[505]; int main() { long long n, k, x, ans; long long A[505]; while (cin >> n >> k) { for (int i = 0; i < n; i++) cnt[i] = 0; for (int i = 0; i < n; i++) cin >> A[i]; x = 0; if (k >= n) { sort(A, A + n); cout << A[n - 1] << end...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class ProblemB { static Scanner sc = new S...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import sys n,k=map(int,raw_input().split()) a=map(int,raw_input().split()) scr={} for i in a:scr[i]=0 p=a p1=p.pop(0) p2=p.pop(0) for i in range(n): if p1>p2: p.append(p2) scr[p1]+=1 p2=p.pop(0) if scr[p1]==k: print p1 sys.exit() break else: ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int m, a[505]; long long k; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> m >> k; for (int i = 0; i < m; i++) { cin >> a[i]; } for (int i = 0; i < m; i++) { bool win = 1; for (int j = 1; j <= min((long long)m - 1, k...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n, k = map(int, input().rstrip().split(' ')) player = list(map(int, input().rstrip().split(' '))) if n <= k: k = n - 1 playWin = 0 count = 0 for i in range(1, n): tempComp = max(player[i], player[playWin]) if player[playWin] == tempComp: count += 1 else: count = 1 playWin = i if count == k: break pr...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Soly { static final int INF = Integer.MAX_VALUE; static void mergeSort(int[] a,int [] c, int b, int e) { if(b < e)...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int main() { int n, r; long long k; cin >> n; cin >> k; int i, a[10000], m = 0; for (i = 0; i < n; i++) { cin >> a[i]; if (a[i] > m) m = a[i]; } if (a[0] == m || k >= n) r = m; else { int c, j, p = 0; for (i = 0; i < n - 1; i++) { ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.util.ArrayList; import java.util.Scanner; public class p879B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); long k = scan.nextLong(); ArrayList<Integer> list = new ArrayList<Integer>(); for (int i = 0; i < n; i++) list.add(scan.nextInt...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; const int N = 555; int n, i; int a[N]; int cnt[N]; int Q[N * N * 10]; long long k; int main() { cin >> n >> k; k = min(k, n - 1LL); for (i = (1); i <= (n); i++) cin >> a[i], Q[i] = i; int L = 2, R = n; int c = 1; while (1) { if (a[c] < a[Q[L]]) { Q[++R...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
b=(list(map(int, input().split()))) a=(list(map(int, input().split()))) n=b[0] k=b[1] l=0 p=0 q=1 while 1: if q%n==0: q=0 if a[p]>=a[q]: if a[p]!=a[q]: l+=1 if l%n==0 or l==k: print(a[p]) break else: p+=1 q=p l=1 q+=1
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.util.*; import java.math.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; //--------------->>>>IF YOU ARE HERE FOR QUICKSORT HACK THEN SORRY NO HACK FOR YOU<<<------------------- public class a{ static long[] count...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#!/usr/bin/env python3 def main(): import collections n, k = map(int, input().split()) k = min(n, k) dq = collections.deque(map(int, input().split())) best = dq.popleft() streak = 0 while streak < k: opp = dq.popleft() if best > opp: dq.append(opp) s...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n,k=map(int,input().split()) a=list(map(int,input().split())) if k>=n: print(max(a)) else: res,z=0,0 for i in range(n+k): if a[res % n]>a[(i+1)%n]: z+=1 else: res,z=i+1,1 if z==k: print(a[res]) break
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; vector<string> vec; long long int sd(long long int n) { long long int sum = 0; while (n != 0) { sum += n % 10; n = n / 10; } return sum; } long long int nd(long long int n) { long long int ans = 0; while (n > 0) { n = n / 10; ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n, k = map(int, input().split()) s = list(map(int, input().split())) if k>=n-1: print(max(s)) else: dic = {} m = s[0] while(1): a, b = max(s[0], s[1]), min(s[0], s[1]) s[1] = a; s.append(b); s = s[1:] dic[a] = dic.get(a, 0) + 1 if dic[a] == k: print(a); break
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n, k = map(int, input().split()) data = list(map(int, input().split())) if k > 3 * n: print(max(data)) exit() q = data cnt = 0 c1, c2 = q[0], q[1] q = q[2:] while cnt < k: if c1 > c2: cnt += 1 else: c1, c2 = c2, c1 cnt = 1 q.append(c2) c2 = q[0] q = q[1:] print(c1) ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const long long K = 2; long long add(long long a, long long b, long long mod) { a %= mod; b %= mod; a += b; if (a >= mod) a -= mod; if (a < 0) { a += mod; a %= mod; } return a; } long long mul(long long a, long long b, ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n, k = map(int, input().split()) players = list(map(int, input().split())) flag = players[0] winCount = k i = 0 while(winCount > 0): if(k > len(players)): maior = 0 for i in range(len(players)): if(players[i] > maior): maior = players[i] flag = maior break if(flag == players[i]): ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n, m = map(int, input().split()) powers = list(map(int, input().split())) max_power = powers[0] wins = 0 if(m < n): for power in powers[1:n]: if(max_power > power): wins +=1 else: max_power = power wins = 1 if(wins == m): break if(m >= n or wins < m): max_power = max(powers) prin...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n, k = map(int, input().split()) a = list(map(int, input().split())) wins = 0 m = max(a) while(wins < k): if a[0] == m: break if(a[0] > a[1]): if a[0] > m: m = a[0] wins += 1 loser = a[1] a.pop(1) a.append(loser) elif(a[1] > a[0]): if a[1] > m: m = a[1] wins = 1 loser = a[0] a.pop(0) a....
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return list(mi()) n, k = mi() a = li() from collections import deque q = deque(a) c = q.popleft() w = 0 while 1: x = q.popleft() if c > x: w += 1 if w >= k or w >= n: ans = c ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; public class B_443 { public static final long[] POWER2 = generatePOWER2()...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; long long k; int n, a[501]; int main(int argc, char *argv[]) { cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; int s = 0; for (int i = 0; i < n; i++) { if (s >= k) { return !printf("%d\n", a[0]); } if (a[0] > a[1]) { s++; } else {...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { long long int n, k, cnt = 0, mxx = 0, curr = 0; scanf("%lld%lld", &n, &k); long long int err[n]; for (int i = 0; i < n; ++i) { scanf("%lld", &err[i]); } curr = err[0]; for (int i = 1; i < n; ++i) { if (err[i] > ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
def tennis(players, consWins, winCount): if consWins >= (len(players)-1): print(max(players)) elif winCount == consWins: print(players[0]) elif players[0] > players[1]: players = [players[i] for i in range(len(players)) if i != 1] + [players[1]] return tennis(players, consWins, winCount+1) elif players[1...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
def main(): n,k = map(int,input().split()) l = list(map(int,input().split())) res = 0 count = 0 if n < k: res = max(l) else: while count != k: if l[0] > l[1]: count +=1 l = swap(l,1) else: count = 1 l = swap(l,0) res = l[0] print(res) def swap(l, i): tmp = l[i] l.pop(i) l.append(...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.util.*; public class p443_2 { public static void main(String args[]) { Scanner ex=new Scanner(System.in); int n=ex.nextInt(); long k=ex.nextLong(); long arr[]=new long[250001]; int st=0,end=n; for(int i=0;i<n;i++) { arr[i]=ex.nextIn...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.awt.List; import java.io.*; import java.util.*; /* * * daiict * * * */ public class prac { FastScanner in; PrintWriter out; static ArrayList[] adj; ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n, k = map(int, input().split()) a = list(map(int, input().split())) curr_streak = 0 curr_power = a[0] for i in range(1, n): if curr_power > a[i]: curr_streak += 1 else: curr_power = a[i] curr_streak = 1 if curr_streak >= k: print(curr_power) exit() print(curr_power) ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; vector<long long> a; for (long long i = 0; i < n; i++) { long long d; cin >> d; a.push_back(d); } long long d = *max_element(a.begin(), a.end()); if (k >= n) { cout << d; } else { long long ans ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; deque<long long> d; long long x; if (k >= n) { long long mx = -1; for (int i = 1; i <= n; i++) { cin >> x; mx = max(mx, x); } cout << mx; } else { for (int i = 1; i <= n; i++) { ci...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n,k=map(int,input().split()) l=list(map(int,input().split())) t,i,j=0,0,1 test=1 if n<k: print(max(l)) test=0 while t<k and test: if l[i]>l[j]: t+=1 j+=1 else: i=j j+=1 t=1 if j==n: j=0 if test: print(l[i])
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.util.*; import java.io.*; import java.math.*; public class Solution{ public static void main(String[] args) { MyScanner sc=new MyScanner(); int n=sc.nextInt(); long k=sc.nextLong(); int arr[]=new int[n]; for(int i=0;i<n;i++) arr[i]=sc.nextInt(); int mx=0; ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n,k = map(int,input().split()) arr = list(map(int,input().split())) winner = 0 h = 0 p = 0 for i in range(1,n): if arr[winner]>arr[i]: h+=1 if h>=k: print(arr[winner]) p=1 break else: winner = i h = 1 if p==0: print(arr[winner])
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.util.*; import java.lang.Math; import java.util.Arrays; import java.util.Scanner; import java.util.stream.IntStream; import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; pu...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; long long pwr(long long base, long long exp, long long mod = (1000000007LL)) { long long res = 1; while (exp > 0) { if (exp % 2) { res = (res * base) % mod; } base = (base * base) % mod; exp /= 2; } return res; } long long gcd(long long a, long...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; long long fx[] = {1, -1, 0, 0}; long long fy[] = {0, 0, 1, -1}; vector<int> p; int main() { long long n, kk; cin >> n >> kk; for (long long i = 0; i < n; i++) { long long val; cin >> val; p.push_back(val); } bool flag = 0; for (long long i = 0; i < p...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
def Winner(wins, A): winStack = [] loseStack = [] count = 0 if wins > 1000: wins = 1000 if A[0] > A[1]: winStack.append(A[0]) loseStack.append(A[1]) count += 1 else: winStack.append(A[1]) loseStack.append(A[0]) count += 1 ind...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n,k = map(int, raw_input().split()) l = list(map(int, raw_input().split())) m = max(l) if k >= n: print(m) else: # Just do it! won = {} for a in l: won[a] = 0 while True: if l[0] > l[1]: won[l[0]] += 1 if won[l[0]] >= k: ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; const int maxN = 600; int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, a[maxN]; long long k, temp; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; } int res = a[0]; temp = 0; for (int i = 1; i < n; ++i) { ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; long long mult(long long a, long long b, long long p = (long long)(1000000007)) { return ((a % p) * (b % p)) % p; } long long add(long long a, long long b, long long p = (long long)(1000000007)) { return (a % p + b % p) % p; } void solve() { long long n...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
from queue import Queue n, k = map(int, input().split()) a = list(map(int, input().split())) q = Queue() for aa in a: q.put(aa) cur = q.get() sec = q.get() if cur > sec: q.put(sec) else: q.put(cur) cur = sec while 1: wins = 1 sec = q.get() while sec < cur: wins += 1 # prin...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n,k=map(int,input().split()) a=list(map(int,input().split())) b=[0]*n if k>=(n-1): print(max(a)) exit(0) while k not in b: if a[0]>a[1]: a.append(a[1]) a.remove(a[1]) b[a[0]-1]+=1 else: a[0],a[1]=a[1],a[0] a.append(a[1]) a.remove(a[1]) b[a[0]-1]+=1...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n,k = map(int, input().strip().split(' ')) lst = list(map(int, input().strip().split(' '))) if k>n: print(max(lst)) else: i=0 c=1 if lst[i]>lst[i+1]: f=lst[i] lst.append(lst[i+1]) del lst[i+1] else: f=lst[i+1] lst.append(lst[i]) del lst[i] while(Tr...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.io.*; import java.util.*; import java.lang.*; import java.math.*; public class Main { static class TaskG { private void solve(int test, FastScanner in, PrintWriter out) { int n = in.nextInt(); long k =in.nextLong(); int a[] = new int[505]; for (...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; const long long INF = LLONG_MAX, MOD = 1e9 + 7; const int L = 17, N = 1 << L; long long n, k; queue<pair<long long, long long> > a; int main() { ios::sync_with_stdio(false); cin >> n >> k; for (int i = 0; i < n; i++) { long long x; cin >> x; a.push({i + 1,...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#codeforces_879B_virtual gi = lambda: list(map(int,input().split())) n,k = gi() powers = gi() if k >= n: print(max(powers)) exit(); wins = 0 while 1: if powers[0] > powers[1]: wins += 1 loser = powers.pop(1) powers.append(loser) else: ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n, k = map(int, raw_input().strip().split()) if k >= n: print max(map(int, raw_input().strip().split())) else: wins = 0 playerArray = map(int, raw_input().strip().split()) currPower = playerArray[0] playerArray = playerArray[1:] while wins < k: if currPower < playerArray[0]: ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.util.Deque; import java.util.LinkedList; import java.util.Scanner; public class Main { private static int[] input = new int[100010]; public static void main(String[] args) { Scanner scan = new Scanner(System.in); int i , j , n , max = - 1; long k; Deque<Integer> queue = new LinkedList<>();...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
# 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...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n, k = map(int, raw_input().split()) a = map(int, raw_input().split()) if k >= n - 1: print n else: curr, wins = a[0], -1 for x in a: if x > curr: curr, wins = x, 0 wins += 1 if wins == k: break print curr
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, k, x; cin >> n >> k; vector<long long int> v; for (int i = 0; i < n; i++) { cin >> x; v.push_back(x); } bool f = true; long long int max = v[0], count = 0; for (int i ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.lang.reflect.Array; import java.util.*; public class Main { static void solve(){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long k = sc.nextLong(); int maxIndex=0; int max = 0; int[]arr = new int[n]; for (int i = 0; i < n; i++) { ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; long long int ciel(long long int x, long long int y) { if (x % y) { return x / y + 1; } return x / y; } long long int perm(long long int n) { return ((n - 1) * n) / 2; } void swap(long long int x, long long int y) { long long int t = x; x = y; y = t; } long ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; int a[n + 1]; for (int i = 0; i < n; i++) { cin >> a[i]; } if (k >= n) { cout << n << "\n"; } else { int wn; if (a[0] > a[1]) wn = a[0]; else wn = a[1]; int c = 1; for (int i =...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; long long m; void solve() { long long n, k, a, b; cin >> n >> k >> a; while (n--) { cin >> b; if (m == k) break; if (a > b) m++; else { a = b; m = 1; } } cout << a; } int main() { ios::sync_with_stdio(0); cin.tie(0); sol...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n,k=map(int,input().split()) ar=list(map(int,input().split())) mx=max(ar) winns={x:0 for x in ar} while True: if ar[0] > ar[1]: if(ar[0]==mx or winns[ar[0]] >= k-1): print(ar[0]) break ar.append(ar.pop(1)) else: ar.append(ar.pop(0)) winns[ar[0]]+=1 ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Queue; import java.util.StringTokenizer; /** * @author Don Li */ public class TableTennis { void solve() { int n = in.nextInt(); l...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; vector<int> v; int a[n], l = 0; for (int i = 0; i < n; i++) { cin >> a[i]; v.push_back(a[i]); } int max = a[0], u = 0; for (int i = 0; i < n; i++) { if (a[i] > max) { max = a[i]; } } i...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
from queue import Queue n, k = map(int, input().split()) a = [int(x) for x in input().split()] q = Queue() if k > n: print(max(a)) else: best, wins = a[0], 0 for i in range(1, n): q.put(a[i]) while True: top = q.get() if best > top: q.put(top) wins += 1...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m; cin >> n >> m; vector<long long int> ve(n); map<long long int, long long int> mp; long long int mx = 0; for (int i = 0; i < n; i++) { cin >> ve[i]; mx = max(mx, ve[i]); } long long int a = n, dem = 0, dem1 = 0; whil...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.io.* ; import java.util.* ; import java.math.* ; public class CodeForces{ public static void main(String[] args) throws IOException{ Solver Machine = new Solver() ; Machine.Solve() ; Machine.Finish(); } } class Mod{ static long mod=1000000007 ; static long d(long a,long b){ return (a*MI(b))%mod ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
firstGiven = input().split() testCase = int(firstGiven[0]) players = input().split() activePlayerOne = int(players[0]) activePlayerTwo = int(players[1]) playerOneWins = -1 playerTwoWins = -1 winCondition = 0 MVP = 0 for x in players: player = int(x) if MVP < player: MVP = player if int(firstGiven[1]) >= testCa...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
# arock # 10/26/2017 # # Codeforces Round #443 - Div. 2 - Problem B n, k = map(int, raw_input().split()) a = map(int, raw_input().split()) if k >= n: print max(a) else: lo = 0 num = 0 win = -1 while True: if a[lo] > a[lo + 1]: if a[lo] == win: num += 1 if num == k: print win exit() els...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
(n, k) = map(int, input().split()) if k > 5000: k = 5000 lst = [] for x in input().split(): lst.append(int(x)) s = [] d = {} win = max(lst[0], lst[1]) out = min(lst[0], lst[1]) lst.remove(out) lst.append(out) s.append(win) d[win] = 1 acc = 0 while acc != k: win = max(s[-1], lst[1]) out = min(s[-1], l...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int main() { int n, a[510]; long long k; scanf("%d %I64d", &n, &k); for (int i = 0; i < n; i++) scanf("%d", &a[i]); if (k + 1 >= n) { sort(a, a + n); printf("%d", a[n - 1]); } else { int MAX = a[0]; int ans = 0, i = 1; while (ans != k) { ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHel...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
from collections import deque q=deque() n,k=map(int,input().split(" ")) a=list(map(int,input().split(" "))) if k>=n-1: print(n) else: for i in range(n): q.append(i) x=q.popleft() np=0 while (np<k): y=q.popleft() if a[x]>a[y]: np+=1 q.append(y) ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.io.*; import java.util.ArrayList; import java.util.List; public class P879B { private static class HpReader { private BufferedReader in; private String containingDirPath; public HpReader(String dir, String inFile, String outFile) { initAndRedirectInOut(dir, inFile, ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int n, a[600]; long long k; int main() { cin >> n >> k; for (int i = (1); i <= (n); i++) scanf("%d", &a[i]); if (k >= n) { cout << n; return 0; } queue<int> q; for (int i = (2); i <= (n); i++) q.push(a[i]); int cnt = 0, cur = a[1]; while (cnt < k) { ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
from collections import deque from functools import reduce n, k = [int(a) for a in input().strip().split()] powers = deque() for a in input().strip().split(): powers.append(int(a)) num_wins = {x: 0 for x in powers} if n == 1: print(powers[0]) elif k > n: print(max(powers)) else: current = None cu...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; import java.util.Deque; import java.util.LinkedList; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long k; cin >> k; if (n <= k) { int ans = -1; while (n--) { int a; cin >> a; ans = max(ans, a); } cout << ans << endl; } else { queue<int> q; for (int i = 0; i < n; i++) { int a; ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#developer at Imperial Arkon n,k = [int(x) for x in input().split()] power = [int(x) for x in input().split()] if k>=n: print(max(power)) else: i=0 while i<n: flag,flag2 = 0,0 # print('i %d'%i) if i==0: withPlayers = i+k+1 else: withPlayers = i+k for j in range(i+1, withPlayers): if j==n: # print...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; long long int fexpo(long long int a, long long int b) { if (b == 0) return 1LL; if (b == 1) return a; if (b == 2) return ((a) * (a)); if (b % 2 == 0) return fexpo(fexpo(a, b / 2), 2); else return ((a) * (fexpo(fexpo(a, (b - 1) / 2), 2))); } int main() { ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#http://codeforces.com/contest/879/problem/B n,k=map(int,input().split()) po=[int(x) for x in input().split()] if n <= k: print(max(po)) exit(0) w=-1 l=-1 i=0 j=i+1 total=0 chn=True while total < k: if po[i] > po[j]: w=i l=j total+=1 po.append(po.pop(l)) chn=True else: if chn: total=0 w=j l=i p...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; long long n, a[10000], k, kk[1000], mx = -10000000, nom; int main() { cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > mx) { mx = a[i]; nom = i; } } for (int i = 0; i < nom - 1; i++) { kk[max(a[i], a[i + 1])]++; a[...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n, k = map(int, input().split()) a = [int(x) for x in input().split()] if k>n-1: print(max(a)) else: count = 0 i = 0 j = 1 found = False while(i<n and j<n): if a[i]>a[j]: count += 1 j += 1 else: count = 1 i = j j += 1 ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.io.*; import java.util.*; public class Main { static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; List<Integer> g[]; class Pair{ int ind; int val; int win; Pair(int ind, int val, int win){ this.ind = ind; this....
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.util.*; import java.lang.*; import java.io.*; public class tt { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); long n=sc.nextLong(); long k=Math.min(n-1,sc.nextLong()); Deque<Long> q=new ArrayDeque<Long>(); for(int i=0;i<n;i++){ ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
nk = input().split() n = int(nk[0]) k = int(nk[1]) sequence = list(map(int, input().split())) wins = k winner = sequence[0] if(k >= n): print(max(sequence)) else: while(wins > 0): if(winner > sequence[1]): wins -= 1 sequence.append(sequence[1]) sequence.pop(1) ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; int main() { int n; long long d; cin >> n >> d; int l; cin >> l; int k; int cnt = 0; for (int j = 1; j < n; j++) { cin >> k; if (k < l) cnt++; else cnt = 1, l = k; if (cnt == d) break; } cout << l << endl; }
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n,k=list(map(int,input().split())) l=list(map(int,input().split())) maxi=max(l) a=max(l[:2]) b=min(l[:2]) l=l[2:] g=k while g: if a==maxi: break if a>b: g-=1 l.append(b) b=l[0] del l[0] elif b>a: g=k-1 l.append(a) a=b b=l[0] del...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
__author__ = 'sushrutrathi' n, k = [int(i) for i in raw_input().strip().split()] arr = [int(i) for i in raw_input().strip().split()] ans = 0 if k >=n: ans = arr[0] for i in range(n): if arr[i]>ans: ans = arr[i] else: i = 0 for i in range(0,n): kk = k j = i + 1 ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; long long w[300003]; long long w1[300003]; map<long long, long long> M, M1; long long a, b, c, n, m, q, k, x, c1, b1, ans; long long poww(long long x, long long y) { if (x == 0) return 0; if (x == 1) return 1; if (y == 0) return 1; if (y == 1) return x; long long ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n = input().split(" ") people_wins = [int(x) for x in n] class Person: def __init__(self, power,wins): self.power = power self.win_count = wins def wins(self): self.win_count +=1 powers = input().split(" ") queue = [Person(int(x),0) for x in powers][::-1] output = "" winner = False tab...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
def pingpong(n,k,a): ans = a[0] wins = 0 for i in range (1,n): if (wins >= k) : return ans if (ans > a[i]): wins = wins + 1 else: wins = 1 ans = a[i] return ans #driver b = list(map(int, input("").split())) n...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; const long long int p_mod = 9999999999999983; const long double pi = 3.14159265358979323; const long long int N = 1e6 + 9; const long long int mod = 1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r) { uniform_int_distribu...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n, k = map(int, input().split()) players = list(map(int, input().split())) flag = players[0] winCount = k i = 0 while(winCount > 0): if(k > n): maior = 0 for i in range(len(players)): if(players[i] > maior): maior = players[i] flag = maior break if(flag == players[i]): i += 1 ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.util.Scanner; public class Codeforces443A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long k = in.nextLong(); int[] pow = new int[n]; for(int i = 0; i<n; i++){ pow[i] = in.nextInt(); } int c = 0; int i = 0; while(c<k){ ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int main() { int n, k; scanf("%d%d", &n, &k); deque<int> dq; for (int i = 0; i < n; i++) { int x; scanf("%d", &x); dq.push_back(x); } int arr[505] = {0}; for (int i = 0; i < n; i++) { int x = dq.front(); dq.pop_front(...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
from collections import deque players=[] p1=0 p2=0 wins=0 isP1Stronk=True n,k=input().split() players=input().split() p1=players[0] players.pop(0) p2=players[0] power=p1 rotations=0 while wins<int(k): if rotations>int(n): break if int(p1)>int(p2): players.append(p2) players.pop(0) ...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import java.io.*; import java.util.*; public class q2 { public static void main(String args[])throws IOException { Scanner in=new Scanner(System.in); PrintWriter out=new PrintWriter(System.out, true); int n=in.nextInt(); long k=in.nextLong(); long power[]=new long[n]; for(int i=0;i<n;i++) power[i]=in.n...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
import bisect import os from collections import Counter import bisect from collections import defaultdict import math import random import heapq as hq from math import sqrt import sys from functools import reduce, cmp_to_key from collections import deque import threading from itertools import combinations from io impor...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
#include <bits/stdc++.h> using namespace std; const int Max = 505; int a[Max]; int main() { int n, pos; long long k; scanf("%d%lld", &n, &k); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); if (a[i] == n) { pos = i; } } if (pos <= k) { printf("%d\n", n); } else { int cnt = 0, i...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
def tableTennis(n, k, powers): players = powers tempWinners = [] if len(powers) == 2: if powers[0] > powers[1]: return powers[0] else: return powers[1] if k > len(powers): return max(powers) while len(tempWinners) < k: challenger = players.pop(0) if not tempWinners else tempWinners[-1] if challe...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n,k=map(int,input().split()) lst=[*map(int,input().split())] mx,cout=lst[0],0 for i in range(1,n): if max(mx,lst[i])==mx:cout+=1 else:mx=lst[i];cout=1 if cout==k:break print(mx)
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
def solve(n,k,a): big = max(a) win_c = 0 for i in range(n): if (a[i] == big): return big for j in range(i+1,n): if (a[i] > a[j]): win_c += 1 else: win_c = 1 break if (win_c == k): return a[i] tmp = input().split() n = int(tmp[0]) k = int(tmp[1]) a = input().split() for i in range(...
Problem: n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each...
n, k = map(int, input().split()) nums = list(map(int, input().split())) player = 0 mp = max(range(n), key=lambda i: nums[i]) while player < n: player1 = max(range(player, n), key=lambda i: nums[i] > nums[player]) if player1 - player - (not player) >= k: print(nums[player]) break if player1 =...