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
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
import java.io.*; import java.text.*; import java.util.*; public class D { public static void main(String[] args) throws Exception { new D().run(); } public void run() throws Exception { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(f.readLine...
JAVA
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; const long long inf = 1e15; int n, m, k; struct flight { int pos, cost; }; long long g1[maxn], g2[maxn], sum1[maxn], sum2[maxn]; vector<flight> G1[maxn], G2[maxn]; int f[maxn]; template <class T> void read(T &x) { x = 0; char c = getchar(); ...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; const int maxn = 1000000 + 9; struct Node { int x, d, c; Node(int _x, int _d, int _c) : x(_x), d(_d), c(_c) {} bool operator<(const Node &o) const { return d < o.d; } }; int N, K; long long mnf[maxn], mnt[maxn]; vector<Node> from, to; int F[maxn]; void Init() { int ...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { char ch; bool flag = false; for (ch = getchar(); !isdigit(ch); ch = getchar()) if (ch == '-') flag = true; for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar()) ; x = flag ? -x : x; } inline void read(long long &x) { ...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; const int MAXD = 1e6 + 10; const long long INF = 1e16; struct e { int p, c, id; }; int Bin[MAXN], BinV[MAXN]; int Bout[MAXN]; int N, M, K, mxD = 0, cnt = 0; priority_queue<pair<int, pair<int, int> > > to[MAXN]; vector<e> Fout[MAXD], Fin[MAXD]; b...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Map; import java.util.TreeMap; public class D { public static void main(String[] args) { FastScannerD sc = new FastScannerD(System.in); int N = sc.nextInt(); //N + 1 cities...
JAVA
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; template <class T1> void deb(T1 e1) { cout << e1 << endl; } template <class T1, class T2> void deb(T1 e1, T2 e2) { cout << e1 << " " << e2 << endl; } template <class T1, class T2, class T3> void deb(T1 e1, T2 e2, T3 e3) { cout << e1 << " " << e2 << " " << e3 << endl; ...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.*; import java.util.function.Function; public class Main { public static void main(String[] args) { InputSt...
JAVA
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; const int MX = 2e6 + 5, N = 1e5 + 5; int n, m, k; vector<pair<int, int> > daysIn[MX], daysOut[MX]; long long costIn[MX], costOut[MX]; multiset<int> sIn[N], sOut[N]; long long ans = 1e9 * 1ll * 1e9; int main() { scanf("%d %d %d", &n, &m, &k); int d, f, t, c; for (int i...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
import java.io.BufferedInputStream; import java.util.*; /** * Created by leen on 23/09/2017. */ public class _853B { public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in, 1024*1024)); int n = scan.nextInt(), m = scan.nextInt(), k = scan.nextInt();...
JAVA
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; bool visited[1000000 + 10]; long long int costin[1000000 + 10], dpin[1000000 + 10]; long long int costout[1000000 + 10], dpout[1000000 + 10]; void fun() { for (int i = 0; i < 1000000 + 5; i++) { dpin[i] = -1; dpout[i] = -1; } } int main() { fun(); int n, m, ...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
import java.util.*; public class JuryMeeting { private ArrayList <Node> arriving, departing; private int n, m, k; private long [] costOfArriving, costOfDeparting; public void minCostsArriving() { Map<Integer,Integer> mp=new HashMap<Integer,Integer>(); long cost=0; for(int i=0; i<arriving.size(); i++) { i...
JAVA
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } const int maxn = 1e5 + ...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; struct hi { int d, f, t, c; }; const int N = 1e6; const long long INF = 1e17; int n, m, k; hi a[N + 5]; void enter() { cin >> n >> m >> k; for (int i = (1), _b = (m); i <= _b; ++i) cin >> a[i].d >> a[i].f >> a[i].t >> a[i].c; } bool cmp(hi p, hi q) { return p.d < ...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; inline void read(long long &x) { x = 0; long long f = 1; char s = getchar(); while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); } while (s >= '0' && s <= '9') { x = (x << 3) + (x << 1) + (s ^ 48); s = getcha...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; long long a[1000005], b[1000005], c[1000005]; int arr[100005], back[100005]; int min_cost1[100005], min_cost2[100005]; int a_num = 0, b_num = 0; struct node { int time, from, to, val; bool operator<(const node& n) const { return time < n.time; } } f[100005]; int main() ...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; const unsigned long long oo = 1ll << 40; const unsigned long long MX = 2000000; struct data { int t, l, c; bool operator<(const data &in) const { return t < in.t; } }; vector<data> v, b; unsigned long long now[MX]; unsigned long long prefix[MX]; unsigned long long suffi...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int M = 1e6 + 5; const int INF = 0x3f3f3f3f; const long long llINF = 0x3f3f3f3f3f3f3f3f; const int mod = 998244353; long long read() { long long x = 0, w = 1; char ch = 0; while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; long long n, m, k, s, l, r, md, cnt, mn = -1, ans, sz[100005], k1[100005], k2[100005], mi[100005], x[100005], y[100005]; bool v[100005]; vector<long long> b[100005], c[100005], u[100005]; struct st { ...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; const long long INF = 1000000000000ll; int main() { int n, m, K; scanf("%d%d%d", &n, &m, &K); K++; vector<vector<pair<int, int> > > af(n), df(n); vector<pair<int, int> > ev(m); for (int t = 0; t < m; t++) { int d, a, b, c; scanf("%d%d%d%d", &d, &a, &b, &...
CPP
854_D. Jury Meeting
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for...
2
10
#include <bits/stdc++.h> using namespace std; const long long MAXX = 1e6 + 5; long long n, m, k; struct ask { long long x; long long st; }; vector<ask> v1[MAXX], v2[MAXX]; long long in[MAXX], out[MAXX]; long long taken1[MAXX], taken2[MAXX]; const long long INF = 1e17; void read() { long long i, j; ask aa; lon...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; long long int p[n], mx = 0; std::vector<long long int> v; for (int i = 0; i < n; i++) { cin >> p[i]; v.push_back(p[i]); if (p[i] > mx) mx = p[i]; } for (int i = 0; i < n; i++) { int cmp = 1; i...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k=[int(i) for i in input().split()] a=[int(i) for i in input().split()] d=a[0] t=0 h=0 for i in range(1,n): if d>a[i]: t+=1 if t>=k: print(d) h=1 break else: t=1 d=a[i] if h==0: print(max(a))
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import queue from collections import deque def readTuple(): return input().split() def readInts(): return tuple(map(int, readTuple())) def solve(): n,k = readInts() if k >= 2000: print(n) return wins = 0 powers = deque(readInts()) while True: a = powers.popleft() ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.Scanner; public class B879 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int a =sc.nextInt(); long b=sc.nextLong(); int[] array=new int[a]; for (int i=0;i<array.length;i++) { array[i]=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
#include <bits/stdc++.h> using namespace std; const int mxn = 505; int n, cnt; long long k, maxi, tmp, a[mxn]; ; int main() { cin >> n >> k; cin >> a[1]; maxi = a[1]; for (int i = 2; i <= n; i++) { cin >> a[i]; if (maxi > a[i]) cnt++; else { if (cnt >= k) { cout << maxi << endl; ...
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
#developer at Imperial Arkon n,k = [int(x) for x in input().split()] power = [int(x) for x in input().split()] i=0 if k>=n: print(max(power)) else: while i<n: flag,flag2 = 0,0 if i==0: withPlayers = i+k+1 else: withPlayers = i+k for j in range(i+1, withPlayers): if j==n: print(power[tempWinner]) fla...
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()) q=list(map(int,input().split())) mx=max(q) if k>=n-1: print(mx) else: i=0 x=0 f=False for r in range(1,n-1): if q[r]>q[i]: i=r x=1 else: x+=1 if x==k: f=True print(q[i]) break...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) a = list(map(int, input().split())) c = a + a if k >= n - 1: print(n) else: for i in range(n): if a[i] > max(c[i + 1:i + 1 + k - 1 * (i != 0)]): print(a[i]) 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
#include <bits/stdc++.h> using namespace std; inline int read() { char c; int s = 0, t = 1; while (!isdigit(c = getchar())) if (c == '-') t = -1; do { s = s * 10 + c - '0'; } while (isdigit(c = getchar())); return s * t; } inline long long readl() { char c; long long s = 0; int t = 1; while ...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) a = list(map(int, input().split())) if k >= n - 1: print(n) else: j = 0 cnt = 0 for i in range(1, n): if a[i] < a[j]: cnt += 1 if cnt == k: print(a[j]) break else: j = i cnt ...
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())) dp = [0] * (n + 1) maxm = max(a[0], a[1]) dp[maxm] = 1 for i in range(2, n): maxm = max(maxm, a[i]) dp[maxm] += 1 if dp[maxm] >= k: ans = maxm break else: ans = max(a) print(ans)
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = tuple([int(x) for x in raw_input().rstrip().split()]) a = [int(x) for x in raw_input().rstrip().split()] if k > len(a): print max(a) else: streak = 0 while(True): w, l = max(a[0], a[1]), min((a[0], a[1])) if w == a[0]: streak += 1 else: streak = 1 ...
PYTHON
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long int n; long long int k; cin >> n >> k; long long int a[n + 1]; for (int i = 0; i < n; i++) { cin >> a[i]; } long long int v[1000] = {0}; long long int ans = 0; for (int i = 0; i < n; i++) { if (a[i] > ans) { ans = a[i];...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k = map(int,input().split()) List = [int(x) for x in input().split()] i = 1 t = 0 Max = List[0] while(i<n): X = max(Max,List[i]) if(X == Max): t+=1 else: Max = X t=1 if(t==k): break i+=1 print(Max)
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; /** * * @author Anjali */ public class Tennis { /** * @param args the command line arguments */ public static void function1(int ar[],long n,long k) { long st=0; int ans = ar[0]; for(int i=1;i<n;i++) { if(st>=k) { ...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
from sys import stdin,stdout n,k = map(int,stdin.readline().split()) p = list(map(int,stdin.readline().split())) if k >= (n-1): p.sort(reverse=True) stdout.write(str(p[0])) else: n1 = p[0] del p[0] c = 0 for item in p: if item > n1: n1 = item c = 1 else:...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = 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
/** * DA-IICT * Author : PARTH PATEL */ import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class B879 { public static int mod = 1000000007; static F...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") using namespace std; long long int MOD = 998244353; double eps = 1e-12; void solve(); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ...
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
firstLine = input().split(' ') n = int(firstLine[0]) k = int(firstLine[1]) secondLine = input() powerArr = [int(x) for x in secondLine.split(' ')] firstMatchPlayed=0 for x in range(n): playerStrength = powerArr[x] playerPos = x xcount =0 j=x+1 if j>n-1: j=0 if f...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> int main() { int n; long long k, now = 0LL; scanf("%d%I64d", &n, &k); int *mas = new int[n * 4], a; for (int i = 0; i < n; i++) { scanf("%d", &mas[i]); mas[i + n + n + n] = (mas[i + n + n] = (mas[i + n] = mas[i])); } a = mas[0]; for (int i = 1; i < n; i++) { if (mas[...
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() { long long int n, k, temp; cin >> n >> k; queue<long long int> q1; for (long long int i = 0; i < n; i++) { cin >> temp; q1.push(temp); } if (k <= n - 1) { long long int count = 0; long long int val = q1.front(); q1.pop(); whil...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) a = list(map(int, input().split())) ans = max(a) tmp = a[0] cnt = 0 for i in range(1, n): if tmp < a[i]: tmp = a[i] cnt = 1 else: cnt += 1 if cnt == k: ans = tmp break print(ans)
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
s=input().split() n=int(s[0]) k=float(s[1]) s=input().split() i=0 a=[] while i<n : a.append(int(s[i])) i+=1 p=0 t=a.index(n) if k<t : while p<k : if a[0]==n : break if a[0]>a[1] : p+=1 if p==k : break a.append(a[1]) ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import Queue N, K = map(int, raw_input().split()) A = map(int, raw_input().split()) Q = Queue.Queue() if (K > N): print max(A) else: B, W = A[0], 0 for i in range(1, N): Q.put(A[i]) while True: top = Q.get() if B > top: Q.put(top) W += 1 else: ...
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()) p = list(map(int, input().split())) best = 0 for x in p: best = max(best, x) wins = 0 b = -1 while wins < k: if p[0] > p[1]: l = p[1] w = p[0] p.pop(1) else: l = p[0] w = p[1] p.pop(0) p.append(l) if w == b: win...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 507 * 507; long long n, k; int a[maxn]; int win[maxn]; int maxx = 0; int main() { cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i], maxx = max(maxx, a[i]); if (n <= k) cout << maxx; else { int l = 0, r = 1; int rr = n; int f = ...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; long long k; cin >> n >> k; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } if (k >= n) { cout << n << endl; return 0; } int cnt; int i, 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
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; long long int k; cin >> n >> k; queue<int> q; int maxx = INT_MIN; for (int i = 0; i < n; i++) { int ele; cin >> ele; maxx = max(maxx, ele); q.push(ele); } if (k >= n - 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
#author: riyan if __name__ == '__main__': n, k = map(int, input().strip().split()) arr = list(map(int, input().strip().split())) i, cnt, ans = 0, 0, 0 while i < n and cnt < k: if ans: if ans > arr[i]: cnt += 1 else: cnt = 1 el...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Scholae { public static void main(String[] args) throws IOException { // BufferedReader in = new BufferedReader(new InputS...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class TableTennis implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; priva...
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: for i in range(k-1): a.append(a[i]) if max(a[0:k+1])==a[0]: print(a[0]) else: i=a.index(max(a[0:k+1])) while True: ma=max(a[i:i+k]) if ma==a[i]: ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
from queue import Queue import sys as os n, k = map(int, input().split()) m = list(map(int, input().split())) max = max(m) q = Queue() c = 0 el = m[0] for i in m[1:]: if i == max: break if el > i: c+=1 else: el = i c = 1 if c == k: print(el) os.exit() print(max)
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-9; const int N = 1e6 + 10; const int M = 1e3 + 10; const long long mod = 1e9 + 7; const long long inf = 1e18; const double f = 0.32349; int a[N]; void solve() { ios::sync_with_stdio(false), cin.tie(0); long long n, k; ...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k = list(map(int,input().split())) arr = list(map(int,input().split())) score = 0 x=0 flag = False while score!=k: # print("Comparing:", arr[x], "&", arr[x+1]) if arr[x] > arr[x+1]: arr.append(arr[x+1]) arr.pop(x+1) score += 1 if flag==True: score += 1 if(arr[x] == max(arr)): br...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) l=list(map(int,input().split())) cnt=1 m=max(l[1],l[0]) for i in range(2,n): if cnt==k: break if l[i]>m: m=l[i] cnt=1 else: cnt+=1 print(m)
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
conditions = input() nums, wins = conditions.split() n = int(nums) k = int(wins) powers = input() powersList = powers.split(' ') powerValues = [int(x) for x in powersList] i = 0 winCounter = [] if(k > 1000): k = 1000 while(len(winCounter) < k): if(powerValues[i] > powerValues[i+1]): winCounter.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; using lli = long long; int di[8] = {-1, 1, 0, 0, -1, 1, -1, 1}; int dj[8] = {0, 0, -1, 1, 1, 1, -1, -1}; const int N = 1.5 * 10000000 + 16; const lli OO = 1e18; string ys = "YES", no = "NO", st; void fast() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int...
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.math.BigInteger; import java.util.*; public class Main { private InputStream is; private PrintWriter out; int time = 0, freq[], start[], end[], dist[], black[], MOD = (int) (1e9 + 7), arr[], weight[][], x[], y[], parent[]; int MAX = 1000001, N, K; long red[], ans = Long.MAX_VALUE; ...
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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; import java.util.ArrayDeque; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Aeroui */ public class Main { public static void main(String[] a...
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 handles cases where wins are > 10000000 has_fought = [] fight_count = 0 while True: fight_count += 1 # handles edge case if(p[0] > p[1]): """ the case is...
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.ArrayList; import java.util.HashMap; import java.util.Scanner; /** * Created by ndzamukashvili on 11/1/2017. */ public class Contest { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long k = sc.nextLong(); int ...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; import java.io.*; public final class Main { public static void main(String[] args) throws Exception { PrintWriter pw = new PrintWriter(System.out); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.rea...
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())) l = 0 k1 = 0 p = 0 while k1 != k and p != n: g1 = A[l] l += 1 g2 = A[l] w = max(g1,g2) A[l] = w A.append(min(g1,g2)) if w == p: k1 += 1 else: p = w k1 = 1 print(p)
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; public class abc { static int[] parent; static long[] size; public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br=new BufferedReader(n...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import os import sys from io import BytesIO, IOBase from collections import deque n, k, a = [None] * 3 def getInput() -> None: global n, k, a n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] def main() -> None: getInput() global n, k, a d = deque(a) 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
#include <bits/stdc++.h> using namespace std; int main(int argc, char* argv[]) { int n, x, a, ans; long long k; scanf("%d %I64d", &n, &k); if (k > n) k = n; n--; scanf("%d", &ans); x = k; while (n--) { scanf("%d", &a); if (x > 0) { ans = max(ans, a); if (ans == a) { x = k - 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 java.io.*; import java.util.StringTokenizer; public class Main { static MyScanner in; static PrintWriter out; public static void main(String[] args) throws IOException { in = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out), false); int n = in.ne...
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()) a = list(map(int, input().split())) if k >= n - 1: print(max(a)) exit() w = [0] * n q = deque() for i in range(n): q.appendleft(i) first = q.pop() while True: second = q.pop() if a[first] < a[second]: first, second = second, fir...
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, l = map(int, input().split()) v = list(map(int, input().split())) occ = 0 max = v[0] for i in range(1, n): if max>v[i]: occ+=1 else: max = v[i] occ = 1 if occ==l: break print(max)
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import sys def sim(powers, k): cur_num_wins = 0 while cur_num_wins < k: if powers[0] > powers[1]: lost = powers.pop(1) powers.append(lost) cur_num_wins += 1 else: lost = powers.pop(0) powers.append(lost) cur_num_wins = 1 ...
PYTHON
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
def solve(a,k): co=0 x=[] if k<len(a): while(co<k): if a[0]>a[1]: te=a[1] del a[1] a.append(te) else: te=a[0] del a[0] a.append(te) x.append(a[0]) if len(...
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, input().split()) a = list(map(int, input().split())) a = deque(a) b = [0] * (n + 1) dk = max(a) while max(b) < k: if a[0] ==dk: print(dk) exit() if a[0] > a[1]: b[a[0]] += 1 aa = a.popleft() bb = a.popleft() a.appendleft(aa) a.append(bb) else: b[a[1]] += ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k=map(int, input().split()) p=list(map(int, input().split())) if k>=n-1: print(max(p)) else: ma=max(p[0:k+1]) i=p.index(ma)+1 win=1 while True: if p[i%n]>ma: ma=p[i] win=1 else: win+=1 if win==k: print(ma) 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
#include <bits/stdc++.h> using namespace std; long long int n, tmp; long long int k, c = 0; list<int> game; int main() { cin >> n >> k; for (int i = 0; i < n; i++) { cin >> tmp; game.push_back(tmp); } while (*game.begin() != n) { if (*game.begin() > *(++game.begin())) { tmp = *(++game.begin())...
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())) if k > n: print(max(a)) exit() st = 0 while st < k: if a[0] > a[1]: st+=1 a.append(a[1]) del a[1] else: st = 1 a.append(a[0]) del a[0] print(a[0])
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception { FastIO2 in = new FastIO2(); int n = in.ni(); long k = in.nl(); int a[] = in.gia(n); if(k>=n-1){ int max = -2; ...
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()) list1 = list(map(int, input().split())) if k >= n: print(max(list1)) else: win = 0 winer = list1[0] flag = True while win < k: if list1[0] < list1[1]: list1.append(list1[0]) list1.pop(0) winer...
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
getInput = input().split() numWins = int(getInput[1]) numPlayers = int(getInput[0]) playerPower = input().split() Power = [] for i in playerPower: Power.append(int(i)) countWin = 0 if len(Power) <= 3: print(max(Power)) elif Power.index(max(Power)) < numWins: print(max(Power)) else: while countWin != n...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
a=input().split(' ') n=int(a[0]) k=int(a[1]) a=input().split(' ') a=[int(i) for i in a] if k>n-1: print(max(a)) exit() wf=0 c=0 cw=a[0] for i in range(1,n-1): cw=max(cw,a[i]) if a[i]==cw: c=1 continue c=c+1 if c>=k: wf=cw print(wf) break else: print(ma...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; long long k; cin >> n >> k; long long a[n]; long long b[n]; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } sort(b, b + n); long long mx = b[n - 1]; long long count = 0; for (int i = 0; i < n; i++) { if (a[i] =...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.String.*; public class Main { public static void main(String[] args) throw...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k = [int(i) for i in input().split()] l = [int(i) for i in input().split()] d = l[0] t = 0 for i in range(1,n): if l[i] < d: t = t+1 else: t = 1 d = l[i] if t == k: break print(d) # Made By Mostafa_Khaled
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 sys import stdin,stdout from collections import Counter from itertools import permutations import bisect import math I=lambda: map(int,stdin.readline().split()) I1=lambda: stdin.readline() #(a/b)%m =((a%m)*pow(b,m-2)%m)%m # for odered set :) def unique(sequence): seen = set() return [x for x in sequence ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
from Queue import Queue def getWinner(n, k, A): Q = Queue() if k >= n: k = n-1 # print "k = ", k for elem in A: Q.put(elem) stay = Q.get() wins = 0 while not Q.empty(): new = Q.get() if stay > new: # print stay, " beat ", new wins += 1 # print "wins = ", wins Q.put(new) if wins >= k: retu...
PYTHON
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; public class Main{ public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); // Start writing your solution here. ------------------------------------- /* int n ...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-9; const long long inf = 1e18; int toint(string s) { int sm; stringstream ss(s); ss >> sm; return sm; } long long tolint(string s) { long long sm; stringstream ss(s); ss >> sm; return sm; } long long a, b, ...
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() { long long n, k, m = LLONG_MIN; cin >> n >> k; queue<long long> q; for (int i = 0; i < n; i++) { long long v; cin >> v; m = max(m, v); q.push(v); } long long count = 0; long long a, b, p; a = q.front(), q.pop(), b = q.front(), q.p...
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
#author: riyan if __name__ == '__main__': n, k = map(int, input().strip().split()) arr = list(map(int, input().strip().split())) if k >= n - 1: ans = n else: i = 0 cnt = 0 ans = -1 while i < n: if cnt == k: ans = arr[i] ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) a=list(map(int,input().split())) max1=max(a) b=[] done=False for i in range(n): b.append(0) m=a.index(max1) if(k>m): print(max1) else: curr=0 for i in range(1,m): if(a[curr]>a[i]): #print(b) b[curr]+=1 else: curr=i ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; vector<long long> v(n); for (int i = 0; i < n; i++) cin >> v[i]; long long d = 0; if (k >= n) cout << n << endl; else { for (int i = 0; i < n; i++) { for (int j = i + 1;; j++) { if (v[i] > v[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.io.*; import java.util.Scanner; public class CF443 { public static void main(String[] argc) { final boolean isTest = false; InputStream is = System.in; OutputStream os = System.out; if(isTest) { try { is = new FileInputStream("test/443.txt"...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; import java.math.*; public class B { public static void main(String args[]) { try { InputReader in = new InputReader(System.in); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); int n = in.readInt(); ...
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()) lst = list(map(int, input().split())) if k >= n-1: print(max(lst)) else: cnt = 0 temp = lst[0] while(True): if temp > lst[1]: cnt += 1 lst.append(lst[1]) lst.pop(1) else: lst.append(temp) lst....
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; long long int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; if (k >= n - 1) { sort(arr, arr + n); cout << arr[n - 1]; } else { list<long long int> q; long long int pos = 1; long long int cn...
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.util.function.IntFunction; import java.util.stream.Collectors; public class Solution { static MyScanner sc; private static PrintWriter out; static long M2 = 1_000_000_000L + 7; public static void main(String[] s) throws Exception { StringBuil...
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 queue(list_, k): wins = 0 while wins < k: if int(list_[0]) > int(list_[1]): index = 1 wins+=1 else: index = 0 wins = 1 list_.append(list_[index]) list_.pop(index) return list_[0] first = input().split() k = int(first[...
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 = [int(f) for f in input().split()] b, pob = 0, a[0] for i in range(1,n): if pob > a[i]: b += 1 if pob < a[i]: pob = a[i] b = 1 if b == k: break print(pob)
PYTHON3