prompt
string
response
string
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.net.Inet4Address; import java.util.*; import java.lang.*; import java.util.HashMap; import java.util.PriorityQueue; public class Solution implements Runnable { static class pair implements Comparable { int f; ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int a[200010]; int b[100001]; int main() { int N, i, j; scanf("%d", &N); for (i = 0; i < N; i++) { int n; scanf("%d", &n); for (j = 0; j < 2 * n; j++) { scanf("%d", &a[j]); } sort(a, a + 2 * n); int m = a[n - 1] - a[n]; if (m >= 0) ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } int main() { ios_base::sync_with_stdio(...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; const long long int INF = (long long int)1e18; const long long int MOD = (long long int)1e9 + 7; const long long int maxn = (long long int)1 * 1e6 + 10, L = 23; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int t; cin >> t; while (t--)...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.util.*; //String[] ss=br.readLine().trim().split(" "); import javafx.util.Pair; import java.util.Map.Entry; import java.io.*; import java.math.BigInteger; public class code { static long MOD=1000000007; // String[] ss=br.readLine().trim().split(" "); public static void main (String[] args) throws IOEx...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import os import sys debug = True if debug and os.path.exists("input.in"): input = open("input.in", "r").readline else: debug = False input = sys.stdin.readline def inp(): return (int(input())) def inlt(): return (list(map(int, input().split()))) def insr(): s = input() return s[:le...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; void Tinh() { int n, a[200010]; cin >> n; for (int i = (1); i <= (2 * n); i++) cin >> a[i]; sort(a + 1, a + 2 * n + 1); cout << a[n + 1] - a[n] << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int q; cin >> q; while (q--) ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t-- > 0) { int n; cin >> n; int a[2 * n]; for (int i = 0; i < 2 * n; ++i) cin >> a[i]; sort(a, a + 2 * n); cout << a[n] - a[n - 1] << "\n"; } return 0...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
cases=int(input()) for _ in range(cases): n=int(input()) c=sorted(list(map(int,input().split()))) l=c[:n] l2=c[n:] print(min(l2)-max(l))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.io.*; import java.math.*; import java.util.*; /* author : Multi-Thread */ public class A { // static int INF = 998244353; static int INF = (int) 1e9 + 7; static int MAX = Integer.MAX_VALUE; static int MIN = Integer.MIN_VALUE; public static void main(String[] args) { int test = fs.nextInt(); /...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[2 * n]; for (int i = 0; i < 2 * n; i++) cin >> arr[i]; sort(arr, arr + (2 * n)); cout << arr[n] - arr[n - 1] << endl; } }
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int an[210000]; int n; int main() { int T; for (scanf("%d", &T); T; T--) { scanf("%d", &n); n = 2 * n; for (int i = 0; i < n; i++) { scanf("%d", &an[i]); } sort(an, an + n); printf("%d\n", abs(an[n / 2 - 1] - an[n / 2])); } return 0; }
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t=int(input()) for i in range(t): n=int(input()) s=[int(value) for value in input().split()] s.sort() print(abs(s[n-1]-s[n]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for _ in range(t): n = int(input()) a = [int(_) for _ in input().split()] a.sort() print(a[n] - a[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t=int(input()) for i in range(t): n=int(input()) s=[int(x) for x in input().split()] s.sort() print(s[n]-s[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) while t: n = int(input()) l = [int(i) for i in input().split()] l.sort() mid2 = len(l)//2 mid1 = mid2-1 print(l[mid2]-l[mid1]) t-=1
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.InputMismatchException; public class B618 { public static int get(ArrayList<Integer> a, ArrayList<Integer> b) { ArrayList<Integer> a2 = new ArrayList<>(); for(int i : a) { a2.add(...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for j in range (int(input())): a=int(input()) l1=list(map(int,input().split())) l1.sort() b=l1[a]-l1[a-1] print(b)
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for i in range(int(input())): k = int(input()) l = list(map(int,input().split())) l.sort() print(abs(l[len(l)//2]-l[(len(l)-1)//2]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; while (t--) { vector<long long> vec; cin >> n; for (int i = 0; i < n * 2; i++) { int khar; cin >> khar; vec.push_back(khar); } sort(vec.begin(), vec.end()); cout << vec[n] - vec[n - 1] << "\n";...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for _ in range(int(input())): n=int(input()) li=list(map(int,input().split())) li.sort() mid=li[n]-li[n-1] print(mid)
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for _ in range(int(input())): n = int(input()) arr = [int(i) for i in input().split()] arr.sort() print(arr[n] - arr[n - 1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for i in range(int(input())): n=int(input()) lis=[x for x in map(int,input().split())] lis=sorted(lis) print(lis[n]-lis[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; const int INF = INT_MAX; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { long long n; cin >> n; long long int a[2 * n]; for (int i = 0; i < 2 * n; i++) { cin >> a[i]; } sort(a, a + 2...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
""" Author: guiferviz Time: 2020-02-09 15:05:02 """ import math def solve(): n = int(input()) a = list(map(int, input().split())) a = sorted(a) print(abs(a[n-1] - a[n])) def main(): t = int(input()) for _ in range(t): solve() if __name__ == "__main__": main()
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long long n, i; cin >> n; long long a[2 * n]; for (i = 0; i < 2 * n; i++) { cin >> a[i]; } sort(a, a + (2 * n)); cout << a[n] - ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for _ in range(int(input())): x = int(input()) l = sorted(list(map(int,input().split()))) print(l[x]-l[x-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split(' '))) a = sorted(a) print(a[len(a)//2] - a[len(a)//2-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int main() { int tc; cin >> tc; while (tc--) { int n; cin >> n; vector<int> arr(2 * n); for (int i = 0; i < 2 * n; i++) cin >> arr[i]; sort(arr.begin(), arr.end()); cout << arr[n] - arr[n - 1] << endl; } return 0; }
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) while t > 0: n = int(input()) students_list = list(map(int, input().split())) students_list.sort() print(students_list[n]-students_list[n-1]) #print(students_list) t -= 1
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for i in range(t): input() a = [*map(int, input().split())] a.sort() l = len(a) print(a[l//2] - a[l//2 - 1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; mt19937_64 mt_rnd_64(chrono::steady_clock::now().time_since_epoch().count()); long long rnd(long long l, long long r) { return (mt_rnd_64() % (r - l + 1)) + l; } using ll = long long; using ld = long double; using ull = unsigned long long; const double PI = acos(-1.0); co...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; int main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; vector<long long int> a(2 * n); for (long long int i = 0; i < 2 * n; i++) cin >> a[i]; sort(a.begin(), a.end()); cout << a[n] - ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
from sys import stdin def main(): input = lambda: stdin.readline()[:-1] T = int(input()) for _ in [0] * T: N = int(input()) A = list(map(int, input().split())) A.sort() ans = A[N] - A[N-1] print(ans) main()
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for __ in range(t): q = int(input()) a = sorted(list(map(int,input().split()))) print(a[len(a) // 2] - a[len(a)//2 - 1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for i in range (t): a = int(input()) b = sorted(list(map(int,input().strip().split()))) print(b[a] - b[a-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for i in range(int(input())): n = int(input()) ar = sorted(map(int,input().split(" "))) print(ar[n]-ar[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import sys, collections tc = int(sys.stdin.readline()) for _ in range(tc): n = int(sys.stdin.readline()) arr = list(map(int, sys.stdin.readline().split())) arr.sort() print(abs(arr[n - 1] - arr[n]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) arr = list(map(int,input().split())) arr.sort() print(arr[n]-arr[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import math def solve(): n = int(input()) table = list(map(int,input().split())) table.sort() print(table[n]-table[n-1]) def main(): T = 1 T = int(input()) while (T): solve() T-=1 if __name__ == "__main__": main()
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); int[] arr = new int[2 * n]; for (int i = 0; ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
T=int(input()) for i in range(T): n=int(input()) l=list(map(int,input().split())) l.sort() print(l[n]-l[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
T = int(input().strip()) for t in range(T): N = int(input().strip()) A = list(map(int, input().split())) A.sort() print(abs(A[N]-A[N-1]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for i in range(int(input())): n = int(input()) a = [int(i) for i in input().split()] a.sort() print(a[n] - a[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t > 0) { long long n, g, i; cin >> n; n = 2 * n; long long a[n]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); g = a[n / 2] - a[n / 2 - 1]; cout << g << "\n"; t--; } }
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; long long int powi(long long int a, long long int x) { long long int ret = 1, tmp = a; while (x) { if (x & 1) ret = ret * tmp % 1000000007; tmp = tmp * tmp % 1000000007; x /= 2; } return ret; } void solve() { long long int n, sum = 0; cin >> n; vec...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
/*** * ██████╗=====███████╗====███████╗====██████╗= * ██╔══██╗====██╔════╝====██╔════╝====██╔══██╗ * ██║==██║====█████╗======█████╗======██████╔╝ * ██║==██║====██╔══╝======██╔══╝======██╔═══╝= * ██████╔╝====███████╗====███████╗====██║===== * ╚═════╝=====╚══════╝====╚══════╝====╚═╝===== * ===...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
T = int(input()) for t in range(T): n = int(input()) A = sorted([int(i) for i in input().split()]) print(A[n]-A[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
# =============================================================================================== # importing some useful libraries. from __future__ import division, print_function from fractions import Fraction import sys import os from io import BytesIO, IOBase # If the element is already present in the list, # the...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for i in range(int(input())): print(max(map(len,input().split("R")))+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import java.util.Scanner; import java.util.Stack; import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedList; import java.util.HashMap; public class C{ public static boolean canJump(ArrayList<Integer> a, int d){ for(int i =0 ;i<a.size()-1;++i) if(a.get(i) + d < a.get(i+1)) return false; ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; while (n--) { int answer = 0, d = 0; string order; cin >> order; order.push_back('R'); for (int i = 1; i <= order.size(); i++) { if (order[i - 1] == 'R') { if (answer <= i - d) answer = i - d; ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t, i, j, x, y; cin >> t; while (t--) { string s; cin >> s; long long cnt = 1; long long ans = 0; for (i = 0; i < s.size(); i++) { if (s[i] == 'L') { ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for _ in range(int(input())): # n=int(input()) # a=list(map(int,input().split())) s=input() n=len(s) ans=[-1] for i in range(n): if s[i]=="R": ans.append(i) ans.append(n) b=[] for i in range(1,len(ans)):b.append(ans[i]-ans[i-1]) print(max(b)) ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string s; cin >> s; int lastR = s.length(); int ans = 0; for (int i = s.length() - 1; i >= 0; i--) { if (s[i] == 'R') { ans = max(ans, lastR - i); lastR = i; } } if (an...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#include <bits/stdc++.h> using namespace std; int main() { int t, len, counter, max_l = 0; char s[200000]; cin >> t; while (t--) { max_l = 0; counter = 0; cin >> s; len = strlen(s); for (int i = 0; i < len; i++) { if (s[i] == 'L') { counter++; if (counter > max_l) max_l...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import java.util.*; public class frogjumps { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0) { String s = sc.next(); char a[] = s.toCharArray(); int count=0,res=0; for(int i=0;i<s.length();i++) { if(a[i] == 'L') count+...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Solution { public static void main( String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); sc.nex...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
t = int(input()) for i in range(t): s = input() max_l = 0 l = 0 flg_s = False for c in s: if c == 'L': if flg_s: l+=1 else: flg_s = True l = 1 else: if flg_s: flg_s = False ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#solution by NAMAN GUPTA testcases = int(input()) #input testcases for i in range(testcases): res,ans = -1,0 #taking list as input L1=list(input()) L1.append("R") L1.insert(0,"R") for idx in range(1,len(L1)): if L1[idx] != "L": DIFF = idx - ans if DIFF > ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
t = int(input()) for i in range(t) : s = input() b = [] for j in range(len(s)) : if s[j] == 'R' : b.append(j+1) b.append(len(s)+1) mx_d = b[0] for j in range(len(b)-1) : mx_d = max(mx_d,b[j+1] - b[j]) print(mx_d) #print(b)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for i in range(int(input())): a=input();s=0;b=[] if set(a)=={"L"}: print(a.count("L")+1) else: for i in a: if i=="R": b.append(s) s=0 else: s+=1 b.append(s) print(max(b)+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
T = int(input()) for i in range(T): n = input() l = [0] for j in range(len(n)): if n[j]=='R': l.append(j+1) diff = [] for j in range(1,len(l)): diff.append(l[j]-l[j-1]) diff.append(len(n)+1 - l[len(l)-1]) print(max(diff))
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import java.util.*; import static java.lang.System.out; public class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner sc=new Scanner(System.in); int t=sc.nextInt(); sc.nextLine(); int f=0,f1=0; while(t-->0){ Str...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import sys input = lambda: sys.stdin.readline().rstrip() for _ in range(int(input())): a=[i for i in input()] ; ind=[-1] for i in range(len(a)): if a[i]=='R': ind.append(i) ind.append(len(a)) maxx=0 for i in range(1,len(ind)): maxx=max(maxx,ind[i]-ind[i-1]) print(max...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { string s; cin >> s; int ans = 0, pos = -1, count = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'R') { if (pos != -1...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
from sys import stdin from collections import deque mod = 10**9 + 7 import sys # sys.setrecursionlimit(10**6) from queue import PriorityQueue # def rl(): # return [int(w) for w in stdin.readline().split()] from bisect import bisect_right from bisect import bisect_left from collections import defaultdict from math i...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
''' ___ ___ ___ ___ ___ ___ /\__\ /\ \ _____ /\ \ /\ \ /\ \ /\__\ /:/ _/_ \:\ \ /::\ \ \:\ \ ___ /::...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int tr = 0; tr < t; ++tr) { string str; cin >> str; int cnt = 0; int ans = 1, lastl = -1; string nw = ""; nw += 'R'; for (int i = 0; i < str.size(); ++i) nw += str[i]; nw += 'R'; for (int i = 0; i ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
q = int(input()) for i in range(q): s = list(input()) + ['R'] ans = 0 cur = 0 for x in s: if x == 'L': cur += 1 else: if ans < cur: ans = cur cur = 0 print(ans + 1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
from collections import Counter from collections import defaultdict import math import random import heapq as hq from math import sqrt import sys from functools import reduce def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def tinput(): return input().split() def r...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
T = int(input()) for t in range(T): s = 'R' + input() + 'R' l = len(s) res = 0 prev = 0 for i in range(1,l): c = s[i] if (c == 'R'): if (i - prev > res): res = i - prev prev = i print(res)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import java.util.*; import java.io.*; public class CodeForces { public static void main(String[] args)throws IOException { Scanner sc=new Scanner(System.in); //Scanner sc=new Scanner(new File("ip.txt")); int tc,a[],i,n,mink,last; char ch; String s; tc=sc.nextInt(); while(tc-->0) { s=sc.next...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
T = int(input()) for _ in range(T): s = 'R' + input() + 'R' lf, mx = 0, 1 for i, ch in enumerate(s): if ch == 'R': mx = max(mx, i-lf) lf = i print(mx)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for _ in range(int(input())): a = p = -1 for i, c in enumerate(input().rstrip() + 'R'): if c == 'R': a = max(a, i-p) p = i print(a)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
t = int(input()) for _ in range(t): s = list(input()) count =0 mx = 0 for c in s: if(c=='L'): count+=1 else: if(count>mx): mx = count count=0 #print(c,count,end=' ') if(count>mx): mx = count pr...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for _ in range(int(input())): a=input() k=a.split("R") lis=[] for i in k: lis.append(len(i)) print(max(lis)+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
inps = int(input()) res = [] count = 0 counts = [] for i in range(inps): x = input() for i in x: if i == 'L': count += 1 else: counts.append(count) count = 0 if 'R' not in x: counts.append(count) count = 0 if x[-1] == 'L': i...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
n = int(raw_input()) for i in range(n): string = raw_input() cont = max(string.split('R'), key=len) print len(cont)+1
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for _ in range(int(input())): s = input() if(s.count('R')==0): print(len(s)+1) else: l=[] l.append(0) for i in range(len(s)): if(s[i]=='R'): l.append(i+1) l.append(len(s)+1) max=0 for i in range(len(l)-1): ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
t = int(input()) for i in range(t): s = "R" + input() + "R" prev = 0 ans = 0 for i in range(1, len(s)): if s[i] == "R": ans = max(ans, i - prev) prev = i print(ans)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
t = int(input()) for _ in range(t): s = input().strip() d = 1 ans = 0 for i in reversed(range(len(s))): if s[i] == 'R': ans = max(ans, d) d = 1 else: d += 1 ans = max(ans, d) print(ans)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
def main(): op='' t=int(input()) for i in range(t): ip=input() j=0 prev_r=0 max_dist=0 r_cnt=0 while j<len(ip): if ip[j]=="R": if r_cnt!=0: max_dist=max(max_dist,j-prev_r) else: max_dist=j+1 r_cnt+=1 prev_r=j j+=1 if max_dist!=0: max_dist=max(max_dist,len(i...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for t in range(int(input())): s = input() sch = 0 x = [] for i in range(len(s)): if s[i] == 'L': sch += 1 else: x += [sch] sch = 0 x += [sch] k = max(x) print(k + 1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import java.io.*; import java.util.*; //import java.math; public class GFG { public static void main (String[] args) { Scanner sc=new Scanner(System.in); int i,n,j,l,x,maxL,t,maxal,ans=1,special; char ch; String s; t=sc.nextInt(); while...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import java.util.*; public class div3_12_3{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int t=in.nextInt(); int temp=t; while(temp>0){ String s = in.next(); int d=0; int lcount=0; int rcount=0; ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import sys t = int(input()) for _ in range(t): nums = input() max_now, max_l = 0, 0 for ch in nums: if ch == 'L': max_now += 1 if max_l < max_now: max_l = max_now else: max_now = 0 print(max_l + 1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
def solve(map_): max_continuous_l = 0 continuous_l = 0 for c in map_: if c == 'R': if max_continuous_l < continuous_l: max_continuous_l = continuous_l continuous_l = 0 elif c == 'L': continuous_l += 1 if max_continuous_l < continuous_...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#include <bits/stdc++.h> using namespace std; string s; vector<int> tab; bool check(int d) { int pt = -1; int ls = -1; while (pt + d < (int)s.size()) { ls = pt; pt = tab[pt + d]; if (ls == pt) return false; } return true; } int main() { ios_base::sync_with_stdio(0); int t; cin >> t; for (i...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
def one(): return int(input()) def more(): return map(int, input().split()) for _ in range(one()): s = input() + 'R' cur = 0 mx = -1 for ind, i in enumerate(s): if i == 'R': d = ind + 1 - cur mx = max(mx, d) cur = ind + 1 print(mx)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
t = int(input()) for i in range(t): a = list(input()) cntMax = 0 cntTmp = 0 for i in range(len(a)): if a[i] == 'L': cntTmp += 1 else: if cntTmp != 0: cntMax = max(cntMax,cntTmp) cntTmp = 0 cntMax = max(cntMax,cntTmp) print(cntMax + 1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int t; cin >> t; while (t--) { string s; cin >> s; long long int maxi = 0, cnt = 0; long long int n = s.length(), i; for (i = 0; i < n; i++) { if (s[i] == 'L') ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int j=0;j<t;j++) { String s=sc.next(); String d="",w="U"; d=d+s+w; int x=0,max=-1,p=0,cnt=0; for(int i=0;i<d.length();i++) { ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
n = int(input()) for _ in range(n): s = input().split('R') maxi = 0 for i in s: if len(i)>maxi: maxi = len(i) print(maxi+1)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
t = int(input()) for _ in range(t): s = input() gl,ll = 1,1 for i in s: if i=="L": ll += 1 else: gl = max(ll,gl) ll = 1 gl = max(ll,gl) print(gl)
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import java.util.*; public class FrogJumps { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int runs = sc.nextInt(); while(runs-->0) { String in = sc.next(); //System.out.println(in); char[] arr = in.toCharArray(); int count = 1; int out = 0; for(int i = 0;i<ar...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
t=int(input()) for z in range(t): a=input() n=len(a) l=[] l.append(0) for i in range(len(a)): if a[i]=='R': l.append(i+1) l.append(n+1) s=[] for i in range(1,len(l)): s.append(l[i]-l[i-1]) s.sort() print(s[len(s)-1])
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
from bisect import bisect_left, bisect_right def go(): # n = int(input()) # a = list(map(int, input().split())) s= input() prev=-1 mx=0 for i, aa in enumerate(s): if aa=='R': mx=max(mx,i-prev) prev=i return max(mx,len(s)-prev) t = int(input()) for _ in rang...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
import java.util.*; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); for(int ii=0; ii<test; ii++){ String s = sc.next(); int n = s.length(); int prev = s.indexOf("R"); ...
Problem: There is a frog staying to the left of the string s = s_1 s_2 … s_n consisting of n characters (to be more precise, the frog initially stays at the cell 0). Each character of s is either 'L' or 'R'. It means that if the frog is staying at the i-th cell and the i-th character is 'L', the frog can jump only to t...
for _ in range(int(input())): s='R'+input()+'R' ans,j=0,0 for i in range(len(s)): if s[i]=='R': if i-j>ans:ans=i-j j=i print(ans)