Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) powers = list(map(int, input().split()))[:n] if k >= n - 1: print(max(powers)) else: wins = 0 index = 0 while True: A = index % n B = (index + 1) % n winner_power = -1 if powers[A] < powers[B]: winner_power = powers[B] wins = 1 else: winner_power = powers[A] 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.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.Scanner; public class test2 { public static void main(String[] args) { Scanner read=new Scanner(System.in); int n=read.nextInt(); long pow=read.nex...
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()) if k > n: k = n arr = list(map(int, input().split())) c = 0 cur = -1 while c < k: if arr[0] > arr[1]: if cur == arr[0]: c += 1 else: cur = arr[0] c = 1 arr = [arr[0]] + arr[2:] + [arr[1]] else: if cur == arr...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int,input().split()) a = list(map(int,input().split())) if(k > n): print(n) else: cur = a[0] hod = -1 ans = n for x in a: if( x > cur): if(hod >= k): ans = min(ans, cur) cur = x hod = 1 else: hod+=1 print (ans)
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; import java.util.Arrays; public class CF5 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); double k = scan.nextLong(); List<Double> arr = new ArrayList<Double>(); for (int i = 0 ; i < n ; i ++) ...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; public class Main { public static void main(String agrs[]) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); long k = scan.nextLong(); int max = Integer.MIN_VALUE; int arr[] = new int[n]; Queue<Integer> queue = ...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, vitorias[550]; long long int powers[550], maior = -1, k; deque<int> jogo; cin >> n >> k; for (i = 1; i <= n; i++) cin >> powers[i], jogo.push_back(i), vitorias[i] = 0, maior = max(maior, powers...
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.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; public class Main { PrintWriter pw; Scanner sc; Main(boolean stdio) throws FileNotFoundException { if (stdio) { pw = new PrintWriter(System.out); sc = new Scanner(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
#include <bits/stdc++.h> using namespace std; int n, can; long long a[10000], sol, k; int main() { scanf("%d %lld", &n, &k); for (int i = 1; i <= n; i++) scanf("%lld", &a[i]); sol = a[1]; for (int i = 2; i <= n; i++) { if (sol > a[i]) can++; else { sol = a[i]; can = 1; } if (ca...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; import java.math.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner cin=new Scanner(System.in); int n=cin.nextInt(); long k=cin.nextLong(); int[] a=new int [550]; for(int i=0;i<n;i++) a[i]=cin.nextInt(); long cnt=0; for(int t=0;t<n;t++) { if...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k = map(int,raw_input().strip().split()) arr = map(int,raw_input().strip().split()) if k>n-1 or n==2: print max(arr) else: atplay = arr[0] arr = arr[1:] wins = 0 ind = 0 while wins<k: if arr[ind%(n-1)]>atplay: atplay,arr = arr[ind%(n-1)],arr[ind%(n-1)+1:]+arr[:ind%(n-1)]+[a...
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; void solve() { long long n, k; cin >> n >> k; vector<pair<int, int>> a(n); int mx = 0; for (int i = 0; i < n; ++i) { cin >> a[i].first; mx = max(a[i].first, mx); a[i].second = i; } vector<pair<int, int>> b = a; vector<int> cnt(n); int ans = -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
#include <bits/stdc++.h> using namespace std; long long n, k, a[507], num[507]; int solve() { deque<int> q; for (int i = 1; i <= n; i++) q.push_back(a[i]); while (1) { int a = q.front(); q.pop_front(); int b = q.front(); q.pop_front(); if (b > a) swap(a, b); num[a]++; if (num[a] >= 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
import sys n,k=map(int,input().split()) a=list(map(int,input().split())) cnt=0 m=max(a) tmp=a[0] for i in range(1,len(a)): if tmp>a[i]:cnt+=1 else: cnt=1 tmp=a[i] if cnt==k: print(tmp) sys.exit() if tmp==m: print(m) sys.exit()
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 300005; const int mod = (long long)1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long k; int n; cin >> n >> k; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int count = 0; for (int i = 0; i < n; i++) { 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
p, n = map(int, input().split()) strength = list(map(int, input().split())) if n >= p: print(max(strength)) else: curmax = strength[0]; curn = 0; for i in range(1,p): if strength[i] > curmax: curmax = strength[i] curn = 1 else: curn += 1 if cu...
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; import java.util.Arrays; import java.util.HashSet; import java.util.Queue; import java.util.LinkedList; public class Problems { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Problems x = new Problems(); counter c = x.new counter(); int n = sc.nextInt(),...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; import java.util.Map.*; public class j { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] str = br.readLine().split(" "); int n = Integer...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) x=list(map(int,input().split())) flag=0 c=k while(flag!=n and c!=0): if(x[0] > x[1]): x.append(x[1]) del x[1] c=c-1 flag=flag+1 elif(x[0] < x[1]): x.append(x[0]) del x[0] c=k-1 flag=0 print(x[0])
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; long long MAXN = (long long)1e6 + 3000; signed main() { long long n, k; cin >> n >> k; vector<long long> a(n); map<long long, long long> wins; long long mx = -1; for (long long i = 0; i < n; ++i) cin >> a[i], wins[a[i]] = 0, mx = max(mx, a[i]); deque<long ...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = list( map( int, input().split() ) ) p = list( map( int, input().split() ) ) if n <= k: print( max( p ) ) else: i = 0 ans = 0 while i < n: j = i+1 fl = False tot = 0 if i > 0: tot = 1 if j < n: while p[i] > p[j] and j+1 < n: j += 1 tot += 1 fl = True if tot >= ...
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
//Codeforces Round #443 (Div. 2) import java.io.*; import java.util.*; public class TaskB { public static void main (String[] args) throws IOException { FastScanner fs = new FastScanner(System.in); PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out)); int n = fs.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
n, k = map(int, input().split()) a = list(map(int, input().split())) wins = 0 bigger = a[0] found = False for i in range(1, n): if bigger == n: print(n) found = True break if bigger > a[i]: wins += 1 else: bigger = a[i] wins = 1 if wins == k: print(bigger) found = True bre...
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 long long N = 1008; long long d[N]; int main() { long long n, k; cin >> n >> k; long long Max = 0; for (long long i = 1; i <= n; i++) { cin >> d[i]; Max = max(Max, d[i]); } long long win = 1; long long id; if (d[2] > d[1]) id = 2; else ...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; public class B implements Runnable{ public static void main (String[] args) {new Thread(null, new B(), "_cf", 1 << 28).start();} public void run() { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n = fs.nextInt(); long k = fs.nex...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
first = input() firstsplit = first.split() n = int(firstsplit[0]) k = int(firstsplit[1]) second = input() players = second.split() players = [int(i) for i in players] wins = 0 if players[0] > players[1]: champion = players.pop(0) wins = wins+1 y = players.pop(0) players.append(y) else: champion = players.pop(1)...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 600; long long n, k; int num; queue<int> que; int main() { ios::sync_with_stdio(false); while (scanf("%I64d%I64d", &n, &k) != EOF) { int Max = 0; while (!que.empty()) { que.pop(); } for (int i = 1; i <= n; ++i) { scanf("%d", ...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, raw_input().split()) a = map(int, raw_input().split()) if k >= n: print max(a) else: p = a[0] c = 0 for i in a[1:]: if i < p: c += 1 else: p = i c = 1 if c == k: break print p
PYTHON
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) powers = list(map(int,input().split())) maxPower=powers[0] wins = 0 for i in range(1,n): if maxPower > powers[i]: wins += 1 else: maxPower = powers[i] wins = 1 if wins == k: break print(maxPower)
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; long long k; cin >> n >> k; vector<int> a(n + 1); int maxx; cin >> maxx; int temp; bool flag = 1; int ans; for (int i = 1; i <= n - 1; i++) { cin >> temp; ...
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() { int n, i, j, vitorias[550]; long long int powers[550], maior = -1, k; deque<int> jogo; scanf("%d %lld", &n, &k); for (i = 1; i <= n; i++) scanf("%lld", &powers[i]), jogo.push_back(i), vitorias[i] = 0, ...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; import java.io.*; /** * 26-Oct-2017 * 8:33:52 PM * @author HulkBuster * */ public class CF879 { public static int mod = (int) (1e9 + 7); public static InputReader in; public static PrintWriter out; public static void solve() throws FileNotFoundException { in = new InputReader(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
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, a, t = 0, maxm = 0, tempmax = 0, k; cin >> n >> k; vector<long long int> A; for (i = 0; i < n; i++) { cin >> a; A.push_back(a); if (maxm < a) maxm = a; } if (k >= n - 1) cout << maxm << endl; else { tempmax ...
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
l1 = raw_input().split() players = int(l1[0]) wins = int(l1[1]) l1 = map(int,raw_input().split()) if players < wins: print max(l1) else: d = {} for i in l1: d[int(i)] = 0 # Number of wins while True: i = int(l1[0]) j = int(l1[1]) if i > j: d[i] += 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; const int maxm = 100005; int a[maxm], flag[maxm]; int main() { long long k; int n, i, j, sum; scanf("%d%lld", &n, &k); for (i = 1; i <= n; i++) scanf("%d", &a[i]); int now = a[1]; for (i = 2; i <= n; i++) { if (now > a[i]) { flag[now]++; if (flag...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; else { return gcd(b, a % b); } } long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); } int main() { long long n, k; cin >> n >> k; long long t = k; long long x, player = ...
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 = input().split() n,k = int(n),int(k) a = [int(i) for i in input().strip().split()] if(k>=n): print(max(a)) else: tmp = a[0] count =0 for i in range(1,n): if(tmp>a[i]): count = count +1 if(count==k): break else: count =1 tmp = a[i] print(tmp)
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())) k1 = k - 1 a1 = max(a[0], a[1]) for i in range(2, n): if a1 > a[i]: k1 -= 1 else: a1 = a[i] k1 = k - 1 if k1 == 0: break print(a1)
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
[n, k] = list(map(int, input().split(' '))) seq = list(map(int, input().split(' '))) if k > n: print(max(seq)) else: currentWinner = max(seq[0], seq[1]) wins = 1 index = 2 while True: if index >= len(seq) or wins == k: break winner = max(currentWinner, seq[index]) ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int i, n, t; long long k, cnt = 0; cin >> n >> k; int cc = (n < k) ? n : k; int *a = (int *)malloc(sizeof(int) * n); for (i = 0; i < n; i++) { cin >> a[i]; } i = 0; t = a[0]; do { i = (++i) % n; if (t > a[i]) { cnt++; ...
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; using namespace std::chrono; void solve() { long long int n, i, m = 0, q = 0, mx = -20000000000000000, mn = 20000000000000000, k = 0, j = 0, c = 0, d = 0, t = 0, sm = 0, pdt = 1, l = 0, r = 0; cin >> n; long long int v[n]; ...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
def main(): n, k = map(int, input().split()) m, *bb = map(int, input().split()) if k < n: c = 0 for i in range(3): aa, bb = bb, [] for a in aa: if m < a: bb.append(m) m, c = a, 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
n = [int(x) for x in input().split(" ")] poderes = [int(x) for x in input().split(" ")] ind = 0 cont = 0 maior = poderes[0] if(n[1] > n[0]): print(max(poderes)) else: while(cont < n[1]): if(ind == n[0]): ind = 0 elif(poderes[ind] == maior): ind+=1 elif(maior > po...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
from collections import deque def ping_pong(wins, players): p = deque(players) i = 0 while i < len(p): wcounter = 0 has_fought = [] fcounter = 0 while True: fcounter += 1 if(p[0] > p[1]): if fcounter == 1 and p[0] > p[-1]: wcounter += 2 else: wcounter += 1 has_fought.append(...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
def main(): n, k = map(int, input().split()) power = list(map(int,input().split())) cnt = 0 win = power[0] del(power[0]) while True: for i in range(0, len(power)): if win > power[i]: cnt = cnt + 1 if cnt >= len(power): print(win) return if cnt >= k: print(win) return els...
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
pV = input().split() p = int(pV[0]) vNeeded = int(pV[1]) powP = list(map(int, input().rstrip().split())) if (p < vNeeded): print(max(powP)) else: win = 0 while win < vNeeded: if int(powP[0]) > int(powP[1]): powP.append(powP.pop(1)) win = win + 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
#what l1 = raw_input().split() players = int(l1[0]) wins = int(l1[1]) l1 = map(int,raw_input().split()) if players < wins: print max(l1) else: d = {} for i in l1: d[int(i)] = 0 # Number of wins while True: i = int(l1[0]) j = int(l1[1]) if i > j: d[i] += 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
n,k=map(int,input().split()) a=list(map(int,input().split())) if k>=n-1: print(max(a)) else: w=a[0];t,q,l=int(w),int(k),max(a) for i in range(1,n): w=max(w,a[i]) if w!=t:q=int(k)-1 else:q-=1 t=int(w) if q==0 or w==l:break print(w)
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
a,b=map(int,input().split()) z=list(map(int,input().split())) r=z.index(max(z));j=0;i=0 while i<r: s=0 if i!=0: if z[i-1]<z[i]:s+=1 for j in range(i+1,r): if z[i]>z[j]:s+=1 else:break if s>=b:exit(print(z[i])) i=max(i+1,j) print(max(z))
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { 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
IL = lambda: list(map(int, input().split())) I = lambda: int(input()) n, k = IL() a = IL() ans = 0 score = 0 for i in range(n-1): if a[0] > a[1]: score += 1 else: score = 1 if score == k: ans = a[0] break p1, p2 = a[:2] a.pop(0) a[0] = max(p1, p2) a.append(mi...
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
size,wins=map(int,raw_input().split()) arr=map(int,raw_input().split()) if wins>(size-1): print max(arr) else: wins_till_now=wins while wins_till_now: first,second=arr[0],arr[1] if first>second: arr.remove(second) arr.append(second) wins_till_now-=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
n, k = map(int, input().split()) powers = list(map(int, input().split())) max_power = max(powers) def get_winner(): i = 0 while True: if powers[i] == max_power: return powers[i] for j in range(i + 1, min(i + k + int(i == 0), n)): if powers[i] < powers[j]: ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k=[int(i) for i in input().split()] list1=[int(i) for i in input().split()] if n==2 or k>10**6: print(max(list1)) else: total=0 player=list1[0] waiter=list1[1:] while total<k: if player>waiter[0]: total+=1 waiter=waiter[1:]+[waiter[0]] else: tota...
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.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.stream.IntStream; import java.util.stream.Stream; /** * Success is not final, failure is not fatal. The courage to continue is what counts. *...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) a=[int(i) for i in input().split()] if n==2: print(max(a)) exit() if k>n: print(max(a)) exit() k+=1 #a=a+a a.insert(0,10**9) for i in range(1,n-k+2): if a[i]==max(a[i-1:i+k-1]) or a[i]==max(a[i:i+k]): print(a[i]) exit() print(max(a[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
// package CF; import java.io.BufferedReader; 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 A { public static void main(String[] args) throws Exception { Scanner sc = 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
n,k=map(int,input().split()) a=list(map(int,input().split())) p=max(a) t=0 if k>600: print(p) else: while t!=k: if a[0]>a[1]: if a[0]==p: print(p) exit() m=a[1] del a[1] a.append(m) t+=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
#include <bits/stdc++.h> using namespace std; int main() { int n; long long k; cin >> n >> k; int a[n]; int i; for (i = 0; i < n; i++) cin >> a[i]; if (k >= n) { int m = a[0]; for (i = 1; i < n; i++) { m = max(m, a[i]); } cout << m; } else { int j; for (j = 1; j < k + 1; 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
n, k = map(int, input().split()) powers = list(map(int, input().split())) curr_player_power = powers[0] curr_player_wins = 0 for i in range(1, n): if powers[i] < curr_player_power: curr_player_wins += 1 else: curr_player_power = powers[i] curr_player_wins = 1 if curr_player_wins ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); long long n, k; cin >> n >> k; int co; queue<int> q; cin >> co; for (int i = 1; i < n; i++) { int t; cin >> t; q.push(t); } int res = n; long long rk = 0; while (co != n) { int va = q....
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n,k=map(int,input().split()) l=list(map(int,input().split())) c=0 if k>=n: print(sorted(l)[-1]) else: while c<k: if l[0]>l[1]: c=c+1 l.insert(n,l[1]) del l[1] else: c=1 l.insert(n,l[0]) del l[0] print(l[0])
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.io.*; import java.util.*; public class A { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); //int[] a = new int[500]; ArrayList<Integer> a = new ArrayList<>(501); 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.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String[] args) throws IOException { // StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); ...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import sys stuff = [int(i) for i in raw_input().split()] n = stuff[0] k = stuff[1] if k > n: print n sys.exit() powers = [int(i) for i in raw_input().split()] scores = [0]*(n+1) while True: if powers[0] > powers[1]: x = powers[1] powers.pop(1) powers.append(x) scores[po...
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
# -*- coding: utf-8 -*- def writeline(l): print " ".join(map(str, l)) def readline(): return map(int, raw_input().split()) def readint(): return int(raw_input(), 10) def main(): n, k = readline() if k >= n - 1: print n else: best = 0 # < any wins = None for a in readline(...
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
nk = list(map(int,input().split())) n = nk[0] k = nk[1] powers = list(map(int, input().split())) p1 = powers.pop(0) p2 = powers.pop(0) w = 0 if k > 10000: k = 10000 while w < k: if p1 > p2: w += 1 powers.append(p2) p2 = powers.pop(0) elif p1 < p2: powers.append(p1) p1 = p2 p2 = powers.pop(0) w =...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long int n, k; int arr[500], max = 0, cnt; bool found = false; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] > max) { max = arr[i]; if (i != 0) cnt = 1; els...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) powers = list(map(int, input().split())) if n <= k: k = n-1 winner = 0 count = 0 for i in range(1, n): if count == k: break new = max(powers[i], powers[winner]) if powers[winner] == new: count += 1 else: count = 1 winner = i print(powers[winner])
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Tennis { private int peopleCount; private long wins; private List<Integer> powers; private int maxPower; //Constructor public Tennis() { this.takeInput(); System.out.println(this.getWinner()); } //Private Met...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, raw_input().split()) powers = map(int, raw_input().split()) cont = 0 player = powers[0] for i in range(1,len(powers)): # print player, cont, powers[i], 'flag' if cont == k: break if player > powers[i]: cont += 1 # print player, powers[i], else: player = powers[i] cont = 1...
PYTHON
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int len; int n[510]; long long int k, c = 0; scanf("%d %lld", &len, &k); for (int i = 0; i < len; i++) scanf("%d", &n[i]); int max_ve = n[0], temp = n[0]; bool f = false; for (int i = 1; i < len; i++) { if (max_ve < n[i]) { max_ve = n[...
CPP
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
def solve(): from collections import deque N, K = map(int, input().split()) dq = deque((map(int, input().split()))) popleft, append = dq.popleft, dq.append win = 0 cur = popleft() while dq: vs = popleft() if cur > vs: win += 1 append(vs) 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
def solve(players,round,queue) : index = 1 currentStrongest = queue[0] winStreak = 0 while index < players and winStreak < round : if currentStrongest < queue[index] : currentStrongest = queue[index] winStreak = 1 else : winStreak += 1 ind...
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(i) for i in input().split()] streak = 0 while streak < k: if a[0] > a[1]: val = a[1] a.remove(val) a.append(val) streak += 1 if a[0] == n: streak = k else: val = a[0] a.remove(val) a.append(val)...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
# -*- coding: utf-8 -*- # Baqir Khan # Software Engineer (Backend) n, k = map(int, input().split()) a = list(map(int, input().split())) if a[0] > a[1]: cur_max = a[0] else: cur_max = a[1] cur_max_len = 1 for i in range(2, n): if a[i] < cur_max: cur_max_len += 1 if cur_max_len == k: ...
PYTHON3
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, raw_input().strip('\n').split()) a = map(int, raw_input().strip('\n').split()) count = 0 pre = 0 flag = 0 for i, x in enumerate(a): if i == 0: pre = x else: if x < pre: count += 1 else: count = 1 pre = x #print pre, count if co...
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 sys n,k=map(int,input().split()) a=list(map(int,input().split())) if k>n: print(n) else: curr=0 currpow=a[0] if currpow==n: print(n) sys.exit() for i in range(1,n): if a[i]>currpow: curr=1 currpow=a[i] if currpow==n: print(n) sys.exit() else: curr...
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; long long arr[n]; for (long long i = 0; i < n; i++) { cin >> arr[i]; } long long power = arr[0]; long long counter = 0; long long p = 0; for (long long j = p + 1; j < n; j++) { if (arr[j] > arr[p] && coun...
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; struct node { int data; int win_time; }; int main() { vector<node> q; int n; long long k; scanf("%d%lld", &n, &k); int Max = 0; for (int i = 0; i < n; i++) { int now; scanf("%d", &now); Max = max(now, Max); q.push_back(node{now, 0}); } fo...
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(x) for x in input().split()] p = [int(x) for x in input().split()] win = p[0] count = 1 for i in range(1,len(p)): if win < p[i]: win = p[i] count = 2 elif win > p[i] and count == k: print(win) break else: count = count + 1 else: print(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; int main() { long long int n, k; cin >> n >> k; int d[n]; int t = 0, ma = -1; for (int i = 0; i < n; i++) { cin >> d[i]; if (d[i] > ma) { ma = d[i]; t = i; } } long long int p = d[0], l = 0; for (int i = 1; i < t; i++) { if (d[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.lang.*; import java.util.*; public class Abhishek { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); long n = Long.parseLong(sc.next()); long k = Long.parseLong(sc.next()); Queue<Long> players = new LinkedList<>(); lo...
JAVA
879_B. Table Tennis
n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner. For each of the p...
2
8
n, k = map(int, input().split()) powers = list(map(int, input().split())) current_plyr_pwr = powers[0] current_plyr_wn = 0 for i in range (1, n): if powers[i] < current_plyr_pwr: current_plyr_wn +=1 else: current_plyr_pwr = powers[i] current_plyr_wn =1 if current_plyr_wn ...
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; vector<long long> vec; int main() { long long n, i, j, k, p, q, x, y; cin >> n >> k; for (i = 0; i < n; i++) { cin >> p; vec.push_back(p); } i = j = 0; while (j < min(n, k)) { if (vec[i] > vec[i + 1]) { swap(vec[i], vec[i + 1]); vec.push_...
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() ) ) p = list( map( int, input().split() ) ) def wins( i ): tot = 0 j = max( 0, i-1 ) while tot < k: if p[j] > p[i]: return ( False ) else: tot += 1 j += 1 j %= n return ( tot == k ) if n <= k: print( max( p ) ) else: i = 0 ans = 0 while i < n...
PYTHON3
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
class polynomial: def __init__(self, data): self.data = data def __lshift__(self, x): return polynomial([0] * x + self.data) def __len__(self): return len(self.data) def __sub__(self, other): newData = [y - x for y, x in zip(self.data, other.data + [0] * 10...
PYTHON3
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
n = int(input()) A = [0 for i in range(n + 1)] B = [0 for i in range(n + 1)] A[0] = 1 for i in range(n): temp = A[:] for j in reversed(range(1, n + 1)): A[j] = (A[j - 1] + B[j]) % 2 A[0] = B[0] B = temp print(n) for i in range(n): print(A[i], end=' ') print(A[n]) print(n - 1) for i in ran...
PYTHON3
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
#include <bits/stdc++.h> using namespace std; long long al[200][200] = {}; long long ar[200][200] = {}; int main() { al[1][0] = 0; al[1][1] = 1; ar[1][0] = 1; al[2][0] = -1; al[2][1] = 0; al[2][2] = 1; ar[2][0] = 0; ar[2][1] = 1; int n; cin >> n; for (int i = 3; i < 160; ++i) { for (int j = 0;...
CPP
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
import java.util.*; public class d { public static void main(String[] args) { int[][] res = new int[151][]; res[0] = new int[]{1}; res[1] = new int[]{0, 1}; res[2] = new int[]{-1, 0, 1}; for (int i=3; i<=150; i++) { res[i] = new int[i+1]; for (int j=1; j<i+1; j++) res[i][j] = res[i-...
JAVA
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
import java.util.Arrays; import java.util.Scanner; public class d { public static int bb = 0; public static int ee = 9; public static void main(String[] Args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][] vs = new int[n + 2][n + 2]; vs[0][0] = 1; vs[1][1] = 1; // vs[2][0] = -1; ...
JAVA
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
#include <bits/stdc++.h> using namespace std; int ans1[505][505], ans2[505][505], p, x = -1, y = -1; int main() { int n; scanf("%d", &n); ans1[1][1] = 1; ans2[1][0] = 1; for (int i = 2; i <= n; i++) { p = 0; for (int j = 0; j <= 200; j++) { if (j) { if (!p) { ans1[i][j] = ans1[...
CPP
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
#include <bits/stdc++.h> using namespace std; int fun[200][200]; int main(void) { fun[0][0] = 1; fun[1][0] = 0; fun[1][1] = 1; int now = 2; int flag = 150; while (flag--) { for (int i = 0; i <= now; ++i) fun[now][i] = fun[(now - 2)][i]; for (int i = 1; i <= now; ++i) fun[now][i] += fun[(now - ...
CPP
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
#include <bits/stdc++.h> using namespace std; int n, a[200][200]; int main() { cin >> n; a[0][0] = 1, a[1][1] = 1; for (int i = 2; i <= 150; i++) { bool check = 0; for (int j = i + 1; j; j--) a[i][j] = a[i - 1][j - 1] + a[i - 2][j], check |= (abs(a[i][j]) > 1); a[i][0] = a[i - 2][0]; if (che...
CPP
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
#include <bits/stdc++.h> using namespace std; vector<int> mult(std::vector<int> V1, std::vector<int> V2) { vector<int> res; vector<int> v1 = V1; vector<int> v2 = V2; reverse((v1).begin(), (v1).end()); v1.push_back(0); reverse((v1).begin(), (v1).end()); res.resize(v1.size()); while (v2.size() != v1.size(...
CPP
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
#include <bits/stdc++.h> using namespace std; int n; int a[160], b[160], c[160]; int main() { int times, i; bool flag; scanf("%d", &n); a[0] = 1; b[1] = 1; for (times = 1; times < n; times++) { c[0] = 0; for (i = 1; i <= n; i++) c[i] = b[i - 1]; for (i = 0; i <= n; i++) c[i] += a[i]; flag = ...
CPP
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3; int a[maxn + 10], b[maxn + 10], tmp[maxn + 10]; void work(int &lena, int &lenb) { for (int i = 0; i < lena; i++) tmp[i + 1] = a[i]; tmp[0] = 0; for (int i = 0; i < lenb; i++) tmp[i] += b[i]; bool flag = true; for (int i = 0; i <= lena; i++) ...
CPP
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int MOD = 1e9 + 7; int a[155], b[155], t[155], m; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); a[1] = 1; for (int i = 1; i <= n; i++) {...
CPP
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
import java.util.Scanner; public class D { private static int[][] p = new int[151][151]; static { p[0][0] = 1; p[1][1] = 1; } public static void main(String[] args) { int n = new Scanner(System.in).nextInt(); for (int i = 2; i <= n; i++) { p[i][0] = p[i-2]...
JAVA
902_D. GCD of Polynomials
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way: <image> This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder o...
2
10
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; while (t--) { int n, i, j, add = -1; cin >> n; vector<int> a, b, c; a.push_back(1); for (i = 0; i < n; i++) { c = a; a.push_back(0); for (j = a...
CPP