exec_outcome
stringclasses
1 value
code_uid
stringlengths
32
32
file_name
stringclasses
111 values
prob_desc_created_at
stringlengths
10
10
prob_desc_description
stringlengths
63
3.8k
prob_desc_memory_limit
stringclasses
18 values
source_code
stringlengths
117
65.5k
lang_cluster
stringclasses
1 value
prob_desc_sample_inputs
stringlengths
2
802
prob_desc_time_limit
stringclasses
27 values
prob_desc_sample_outputs
stringlengths
2
796
prob_desc_notes
stringlengths
4
3k
lang
stringclasses
5 values
prob_desc_input_from
stringclasses
3 values
tags
listlengths
0
11
src_uid
stringlengths
32
32
prob_desc_input_spec
stringlengths
28
2.37k
difficulty
int64
-1
3.5k
prob_desc_output_spec
stringlengths
17
1.47k
prob_desc_output_to
stringclasses
3 values
hidden_unit_tests
stringclasses
1 value
PASSED
f9e0c6251cad533b8b5c31187fd74af1
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class Main { static Scanner sc = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); // long mod = 998244353; // long mod = (long)1e9...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
35656e48f30c632ff40d5ee3a1634c18
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); new Main().run(in, out); out.close(); } public static long mod =...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
08f20aa83c963ae9402b88904f1495ae
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String args[]) {new Main().run();} FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run(){ work(); out.flush(); } long mod=1000000007; long gc...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
26b301075d21f8e65e5e518cf913bf3a
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
/** * BaZ :D */ import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main { static MyScanner scan; static PrintWriter pw; static long MOD = 1_000_000_007; static long INF = 2_000_000_000_000_000_000L; static long inf = 2_000_000_000; public stat...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
686386571aaf4727e98dd554f3156c1e
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.concurrent.TimeUnit; public class d1486 implements Runnable{ public static void main(String[] args) { try{ new Thread(null, new d1486(), "process", 1<<26).start(); } catch(Exception e){ ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
be8fdce4e3f212606a237fd463feabae
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; /** * * @Har_Har_Mahadev */ public class D { private static long INF = 2000000000000000000L, M = 1000000007, MM = 998244353; private static int N = 0; public static void process() throws IOException { int n = sc.nextInt(),k = sc.next...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
fe26c478987d63f4430718ad133c1914
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class D { public static void main(String[] args) { FastScanner sc = new FastScanner(); int n = sc.nextInt(); int k = sc.nextInt(); int[] arr = new int[n]; for(int i = 0; i < n; i++){ arr[i] = sc.nextInt(); } int a = 1, b = n+1; while(b - a >...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
0b60e8a3cba4ba675a8270c5df42761a
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class Main { static long startTime = System.currentTimeMillis(); // for global initializations and methods starts here // global initialisations and methods end here static void run() { boolean tc = false; AdityaFastIO r = ne...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
23ee3032217da01fd4bf4c6215271906
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import com.sun.org.apache.regexp.internal.RE; import java.util.*; public class Main { static int N = (int)2e5+10; static Scanner scan = new Scanner(System.in); static int[] a = new int[N]; static int[] sum =new int[N]; static int n; static int k; static boolean check(int x){ ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
5fc0a926531af0d90a4f0bd66b9908fb
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class Main { static int mod = (int) 1e9 + 7; static int[][] matMul(int[][] A, int[][] B, int p, int q, int r) // C(p x r) = A(p x q) x (q x r) -- O(p x q x r) { int[][] C = new int[p][r]; for (int i = 0; i < p; ++i) for (int j = 0; j < r; ++j) fo...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
5c505895d6eb92446fd8aa00dc0c2f1a
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class Main { static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); public static void main(String[] args) throws Exception { String [] s = in.readLine().s...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
1145e3703847a4fba68b25f3fdb58de6
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.File; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; public class Main { static Scanner in = new Scanner(System.in); // static Scanner in = new Scanner( new File("javain.txt")); public s...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
46f20891d0caa65cbaf7423c1244f2e0
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.Arrays; import java.util.Formatter; import java.util.Random; /** * Coder: SumitRaut * Date: 27-02-2021 14:23 */ public class Main { public static void main(Stri...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
434c78b0555b33b834119538d1011e1e
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.*; public class Main { static class point { long val, time, t3; point(long val, long time, int t3) { this.val = val; this.time = time; ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
bc5ec4cd6e99211dc18a24900ac746c6
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.stream.IntStream; import java.util.Arrays; import java.io.IOException; import java.util.OptionalInt; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.Buffer...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
be4aff2ba780e637b083021034493ff5
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class maxmedian { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(f.readLine()); int n = Integer.parseInt(st.nextToken()); int k = ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
c6b3e7953266e542a370fdf987b516e0
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; /* polyakoff */ public class Main { static FastReader in; static PrintWriter out; static Random rand = new Random(); static final int oo = (int) 1e9 + 10; static final long OO = (long) 2e18 + 10; static final int MOD = (int) 1e9 + 7; ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
dff8c282cd5225faa3a47e2e04113f83
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
//package com.company; import java.io.*; import java.util.*; public class Main { static FastReader sc = new FastReader(); static PrintWriter out = new PrintWriter(System.out); private static int N = 200005; private static int[] a = new int[N]; private static int[] b = new int[N]; priv...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
25460dc785c10b2a21e7ed8069c9d2a5
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.awt.font.TextMeasurer; import java.io.*; public class Main { public static void main(String[] args) throws Exception { int n=sc.nextInt(); int k=sc.nextInt(); Integer[]a=sc.nextIntegerArray(n); Integer[]b=a.clone(); Arrays.sort(b); int low=0; int high=n-1; ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
abe77143ba75bfa0a9f7d1ca5c089672
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class Solution { private static boolean TESTS = false; private final Input in; private final PrintStream out; public Solution(final Input in, final PrintStream out) { this.in = in; this.out = out; } ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
6d22c250b69df1f8c99a031d6bc55e57
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.lang.reflect.Type; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.*; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.Future; import java.util.concurrent.FutureTas...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
d7993a03b1735828a917af8e589c73a6
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Main{ public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputSt...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
c4f04186090c7e7621cc693742a2a344
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class D { public static void main(String[] args) { FastScanner in = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t = 1;//in.nextInt(); while(t-->0) { int n = in.nextInt(), k = in.nextInt(); ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
357c1d7eaa0ec368b7922f6c08433843
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class D { private static boolean check(int[] a, int N, int K, int val) { int[] arr=new int[N]; int i; for(i=0;i<N;i++) arr[i]=a[i]<val?-1:1; int[] pref=new int[N+1]; int cur=0; for(i=0;i<N;i...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
418146a8559d28c15ab30c4225f5756e
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.List; import java.util.*; public class realfast implements Runnable { private static final int INF = (int) 1e9; long in= 1000000007; long fac[]= new long[1000001]; lo...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
99387974322ebefbb7f4732526bc7265
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class Div708 { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 8
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
f6d4cb7772f0e003a247efd27ff39426
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.System.out; import java.util.*; import java.io.*; import java.math.*; /* getOrDefault valueOf char[] arr=st.nextToken().toCharArray(); System.out.println(); List<Integer> l...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 17
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
228c9a2a957845d3a0dad5cb2fba6ec7
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; public class MaxMedian { public static void main(String... strings) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int k = scanner.nextInt(); int[] a = new int[n]; for(int i = 0 ;i < n;i++){ a[i]=scanner.nextInt(); } solve(k,n,a); } pub...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
331dbace4c20b5163bc80601ecb7dcf3
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import java.util.zip.CheckedInputStream; public class MaxMedian { static boolean isMedian(int[] arr, int median, int k, int n) { int[] diff = new int[n]; int[] pre...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
f854e43dbb99cdc87101e071858082ea
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import java.util.zip.CheckedInputStream; public class MaxMedian { static boolean isMedian(int[] arr, int median, int k, int n) { int[] diff = new int[n]; int[] pre...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
263747c89686a51528f62bf98d7af3ac
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.Scanner; public class G_PRO { public static void main(String[] args) { Scanner cin = new Scanner(System.in); //所有数组都从1开始 int n = cin.nextInt(); int k = cin.nextInt(); int[] a = new int[n + 1]; int maxValue = 0; for (int i = 1; i <...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
3a3cd575a72d232107c6ec4888e61e8f
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
//package credit; import java.io.*; import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class x{ static boolean v[]; static int ans[]; int size[]; static int count=0; static int ds...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
a6ef5526a7fabe3f626de235850dd7d0
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public final class D { public static void main(String[] args) { final FastScanner fs = new FastScanner(); fina...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
921d7fccc3e012c9e6a9c2fe4ab3fb63
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public final class D { public static void main(String[] args) { final FastScanner fs = new FastScanner(); ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
e226d72b00f09d9333a87a7ac512f4f2
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class MaxMedian { static int n, k; static int[] arr; public static void main(String[] args) throws IOException{ BufferedReader file = new BufferedReader(new InputStreamReader(System.in)); //BufferedReader file = new BufferedReader(new FileRe...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
37db6203acb48d813abe94ad239988e6
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class D { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); int k = scn.nextInt(); int[] arr = new int[n]; int[] sortedArr = new int[n]; for (int i...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
174bde41f15b1ea14d63351f859f56ca
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { static int bs(int start,int end,int[] l,int k) { // System.out.println(start+" "+end); if(end<start) { return -1000000000; } int mid=(start+end)/2; int n=l.length; int[] temp=new int[n]; int[] mn=new int[n+1]...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
fee1f85940a2623df3e3ef0aef7bdb82
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { static int bs(int start,int end,int[] l,int k) { // System.out.println(start+" "+end); if(end<start) { return -1000000000; } int mid=(start+end)/2; int n=l.length; int[] temp=new int[n]; int[] mn=new int[n+1]...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
660de630b2a5596d6494af7b9ef3f03d
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.math.BigInteger; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Ar...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
67357643a8029f9ad33684286ceab097
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.math.BigInteger; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Ar...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
b697a2ec13d28e7fd9f07a6cba0dbbef
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
/* 5 3 1 2 3 2 1 100 64 43 30 88 55 14 10 78 99 6 29 10 79 11 96 7 20 37 65 79 78 46 62 37 47 37 60 4 28 24 9 87 4 20 94 47 95 100 13 60 24 34 4 89 63 65 20 11 68 99 47 41 38 37 23 23 13 3 1 39 28 65 95 98 44 64 58 77 11 89 49 58 30 77 20 94 40 15 17 62 92 9 91 27 23 24 74 92 60 91 40 88 14 44 75 25 73 51 4 31 25...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
39c45cbb134844197a23d176f5a5f105
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.awt.*; // U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE................ //JUst keep faith in ur strengths .................................................. // ASCII = 48 + i ;// 2^28 = 268,435,456 > 2* 10^8 // log 1...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
48d9fa37d60afd8ea45fff7a978c762e
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
// d import java.util.*; // import java.lang.*; import java.io.*; // THIS TEMPLATE MADE BY AKSH BANSAL. public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStre...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
c431aebf51962325431e386815fbae3f
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class D { private static PrintWriter out; private static class FS { StringTokenizer st; BufferedReader br; public FS() { br = new BufferedReader(new InputStreamReader(System.in)); } public String next() { while (st == null || !s...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
fe1872d1a04d0cac006b6792a2c9e76c
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Solution { static Reader input = new Reader(); static int n, k, t, r, sum, temp; static int[] a, arr, leftSum, rightSum, maxRight, maxLeft; public static vo...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
993f043aad39efa4f677b2b7e82cc3b9
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class MaxMedianBinarySearch { public static void main(String[] args) throws IOException { ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
8fb1265b98ff56437f64b6cf6a17f1e2
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class MaxMed2 { public static void main(String[] args) throws IOException{ BufferedReader f=new BufferedReader(new InputStreamReader(System.in)); PrintWriter out=new PrintWriter(System.out); StringTokenizer st=new StringTokenizer(f.readLine()); int n=Integer.parse...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
6f56dde4df78de423cc4c34417010e4f
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class _1486_D { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer line = new StringTokenizer...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
567ff306aa287ba3a6740072e462ca4b
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class CFMaxMedian1486 { public static int n; public static int k; public static int[] array; public static void main (String[] args) throws IOException { BufferedReader r= new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new Prin...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
aaa41bd0a8d4567ec7ebd6bbc74caa8d
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
//package Algorithm.BinarySearch.Important; import java.util.Arrays; import java.util.Scanner; public class Max_Median { static int n, k; public static void main(String[] args) { Scanner scan = new Scanner(System.in); n = scan.nextInt(); k = scan.nextInt(); int[] a = new int[...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
1865ad47e0ddb331a70d0edab20d25f9
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class MaxMedian { static int n, k; public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader scan = new BufferedReader(new InputStream...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
c4d577da946d97e40a9926f32ca57005
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.InputMismatchException; import java.util.*; import java.io.*; import java.lang.*; public class Main{ public static class InputReader { private InputStream strea...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
a2815047eaf5627c81b33a37fbbc03fb
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; @SuppressWarnings("unchecked") public class MaxMedian implements Runnable { void solve() throws IOException { int len = read.intNext(), k = read.intNext(); int[] arr = iArr(len); for(int i = 0; i < len; i++ ){ arr[i] = read.intNext(); } int l = 1, ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
d5b75ff9380ee69aa4f8b23c2e80b145
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); String s[]=bu.readLine().split(" "); i...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
177e14ed04e50bbb33be6f5636d81638
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; //My life seems to be a joke. But, one day I will conquer. public class B{ public static void main(String[] args) { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n = fs.nextInt(); int k = fs.nextInt(); int[] arr = fs.readA...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
8ffcd55357f8fabfa08cb37ac76dde3b
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class problemD { static class Solution { void solve() { int n = fs.nextInt(); ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
280995a8547d873b01cf66715e5fc548
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
/* "Everything in the universe is balanced. Every disappointment you face in life will be balanced by something good for you! Keep going, never give up." Just have Patience + 1... */ import java.util.*; import java.lang.*...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
ceca32490727141bc16b7d5fb8340bbe
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //int cases = Integer.parseInt(br.readLine()); //o:while(cases-- > 0) { String[] str = br.readLine().s...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
54fc785251a0b3326e08413dec5e5e8d
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
//package maxmedian; import java.util.*; import java.io.*; public class maxmedian { public static boolean isValid(int[] nums, int val, int k) { TreeSet<Integer> before = new TreeSet<Integer>(); int sum = 0; int beforeSum = 0; for(int i = 0; i < k; i++) { if(nums[i] >= val) { sum ++; ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
90ca87f0cf72f46c1f90b0b070605f73
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.DataInputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; public class Main { private static void run() throws IOException { int n = in.nextInt(); int k = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
3f28d5ee11a084ab1f4269a4d52ca453
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class Main { static BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(System.out)); static StringTokenizer tok; public static void main(String[] args) throws Exception { ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
d1ae4509311e654204f1e96f2305ca3a
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
/* Codeforces Problem 1486D */ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; public class MaxMedian { public static void main(String[] args) throws IOException { FastIO in = new FastIO(System.in); int n = in.nextInt(); int k = in.nextInt(); in...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
8a97d45c534c7d386737c2fb46189532
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.ArrayDeque; import java.util.Queue; import java.util.Scanner; public class d1486 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int length = in.nextInt(); int minSubarrayLength = in.nextInt(); int[] array = new int[length]; int min = Integer.MAX_VA...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
4e03ba99b39e3d910fd93c158816ae0d
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { public static void main(String[] args) throws java.lang.Exception { out = new PrintWriter(new BufferedOutputStream(System.out)); sc = new FastReader(); int test = 1; for (int t = 0; t < test; ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
b4c724ad75d27753fe0558d4c0ed5bd8
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { public static void main(String[] args) throws java.lang.Exception { out = new PrintWriter(new BufferedOutputStream(System.out)); sc = new FastReader(); int test = 1; for (int t = 0; t < test; ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
836b5f03f87bc364f9a081eed4174d84
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
// coached by rainboy import java.io.*; import java.util.*; public class CF1486D extends PrintWriter { Scanner sc = new Scanner(System.in); CF1486D() { super(System.out, true); } public static void main(String[] $) { CF1486D o = new CF1486D(); o.main(); o.flush(); } void main() { int n = sc.nextInt(); int ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
41f2c9882ab35b70bcce2d1a092addb3
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class Main{ private static final String name = "triangles"; private static PrintWriter out; private static FastIO sc; private static final int mod = 1_000_000_007; public static void main(String[] args) throws Exception { try{ sc = new FastIO(na...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
437b9f3cd0d5c9221b262e2f03d39ae2
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.Scanner; public class Solution { public static void main(String[] args) { int N , M; Scanner scan = new Scanner(System.in); N=scan.nextInt(); M=scan.nextInt(); int[] a = new int[N+1]; int[] b = new int[N+1]; int[] s = new int[N+1]; ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
3bd9195c5b95721970b595e05723abea
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class MaxMedian { static FastScanner fs; static FastWriter fw; static boolean checkOnlineJudge = System.getProperty("ONLINE_JUDGE") == null; private static final int iMax = (int) (2e9), iMin = (int) (-2e9); private static final long lMax = (i...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
7f11996c4dc0e8c386fe9fe454a1922e
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { private static final String NO = "NO"; private static final String YES = "YES"; InputStream is; ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
1673e4971f5b5847e036df612e9bbd4d
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; public class Sol{ public static void main(String [] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); int a[]=new int[n]; int b[]=new int[n]; for(int i=0;i<n;i++){a[i]=sc.nextInt();} int l=1;int r=n+1; while(r-l>1){ ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
984dc2232971d491442162038b57c2c0
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class CF { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st =...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
0c839a26af3777a6887eb382d1451d57
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; public class cf703 { public static Scanner sc = new Scanner(System.in); public static int problemA(int n, int arr[]){ long tillNow=0; for(int i=0; i<n; i++){ tillNow+=arr[i]; if(tillNow<i) return 0; tillNow-=i; } return 1...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
6b3af662a23a7a566b71963760b7dd2f
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class Template { static long[] c = new long[(int)1e6+8432]; static long[] b = new long[(int)1e6+8432]; public static void main(String[] args) { FastScanner sc = new FastScanner(); // int yo = sc.nextInt(); // while (yo-- > 0) { int n = sc.nextInt(); ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
f520cc8532a9ddb41d8d8e4ad85e4bba
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class CF703D { public static final int N = (int)(2e5); public static int n, k; public static int[] a, b, c; public static SegmentTree T; static class SegmentTree { ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
e0b82b381da7bc99f76ca2bec96a80f0
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.Scanner; public class Index { static final int MAXN = 200005; static int n, k; static int[] a = new int[MAXN]; static int[] b = new int[MAXN]; static int[] sum = new int[MAXN]; static Scanner scan = new Scanner(System.in); static boolean check(int x) { for (int i =...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
638aa73a8f8e60eb7cf74aec76a27ab1
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class abc { static BufferedReader br; public static void main(String ard[])throws IOException { br=new BufferedReader(new InputStreamReader(System.in)); String s[]=br.readLine().split(" "); int n=Integer.parseInt(s[0]); ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
dc7d4431502d37cf3fb4a56a9fc220fd
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class D { public static class FastIO { BufferedReader br; BufferedWriter bw, be; StringTokenizer st; public FastIO() { br = new BufferedReader(new InputStreamReader(System.in)); bw = new BufferedWriter(new OutputStreamWriter(System.out)); ...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
1afc784abccd39937c6ee382bdd9df24
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Arrays; import java.util.Random; import java.io.FileWriter; import java.io.PrintWriter; /* Solution Created: 12:43:51 20/02/2021 C...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
310993266febbcbda7fee5d9241c41ff
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.io.*; import java.util.*; public class A { static int n, k; static int[] arr; static char[] s; public static void main(String[] args) throws IOException { f = new F...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
4f43b768df1c772b892841b810d69d09
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
//package com.company; import java.io.*; import java.util.*; public class Main { static FastReader sc = new FastReader(); static PrintWriter out = new PrintWriter(System.out); private static int N = 200005; private static int[] a = new int[N]; private static int[] b = new int[N]; priv...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
b775db0434e50b5f6a26f062218278bf
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; public class Maxmed { public static void main(String[] args) { int n, k; Scanner in = new Scanner(System.in); n = in.nextInt(); k = in.nextInt(); int[] nums = new int[n]; for (int i = 0; i < n; i++) { nums[...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
1ecbbc4a757175957c59bbb1613c110f
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Main { public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); static long MOD = (long) (1e9 + 7); //static int MOD = 998244353; static long MOD2 = MOD * MOD; static FastReader sc = new FastReader(...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
50fb9f254fe31a72699e9f829b291e83
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
import java.util.*; import java.io.*; public class _703 { static MyScanner sc; public static void main(String[] args) { sc = new MyScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int t = 1; while (t-- > 0) { int n = sc.ne...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
5ccb8dcb40044e742ce9e0a030be121c
train_110.jsonl
1613658900
You are a given an array $$$a$$$ of length $$$n$$$. Find a subarray $$$a[l..r]$$$ with length at least $$$k$$$ with the largest median.A median in an array of length $$$n$$$ is an element which occupies position number $$$\lfloor \frac{n + 1}{2} \rfloor$$$ after we sort the elements in non-decreasing order. For example...
256 megabytes
//package round703; import java.io.*; import java.util.ArrayDeque; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Queue; public class D { InputStream is; FastWriter out; String INPUT = ""; void solve() { int n = ni(), K = ni(); int[] a = na(n); int low =...
Java
["5 3\n1 2 3 2 1", "4 2\n1 2 3 4"]
2 seconds
["2", "3"]
NoteIn the first example all the possible subarrays are $$$[1..3]$$$, $$$[1..4]$$$, $$$[1..5]$$$, $$$[2..4]$$$, $$$[2..5]$$$ and $$$[3..5]$$$ and the median for all of them is $$$2$$$, so the maximum possible median is $$$2$$$ too.In the second example $$$median([3..4]) = 3$$$.
Java 11
standard input
[ "binary search", "data structures", "dp" ]
dddeb7663c948515def967374f2b8812
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq k \leq n \leq 2 \cdot 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$).
2,100
Output one integer $$$m$$$ — the maximum median you can get.
standard output
PASSED
9bb234ac445aadc3292e541abb547ba0
train_110.jsonl
1613658900
You are given a tree consisting of $$$n$$$ vertices, and $$$m$$$ simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the number of pairs $$$(i, j)$$$ $$$(1 \leq i &lt; j \leq m)$$$ such that $$$path_i$$$ and $$$path_j$$$ have exactly on...
512 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; public class OnePointPathsLog { static final int jumps = 19; static int[][] parents; static...
Java
["5\n1 2\n1 3\n1 4\n3 5\n4\n2 3\n2 4\n3 4\n3 5", "1\n3\n1 1\n1 1\n1 1", "5\n1 2\n1 3\n1 4\n3 5\n6\n2 3\n2 4\n3 4\n3 5\n1 1\n1 2"]
6 seconds
["2", "3", "7"]
NoteThe tree in the first example and paths look like this. Pairs $$$(1,4)$$$ and $$$(3,4)$$$ intersect at one vertex.In the second example all three paths contain the same single vertex, so all pairs $$$(1, 2)$$$, $$$(1, 3)$$$ and $$$(2, 3)$$$ intersect at one vertex.The third example is the same as the first example ...
Java 8
standard input
[ "combinatorics", "data structures", "dfs and similar", "dp", "trees" ]
632afd3c714e4ab34fbc474f9f99d345
First line contains a single integer $$$n$$$ $$$(1 \leq n \leq 3 \cdot 10^5)$$$. Next $$$n - 1$$$ lines describe the tree. Each line contains two integers $$$u$$$ and $$$v$$$ $$$(1 \leq u, v \leq n)$$$ describing an edge between vertices $$$u$$$ and $$$v$$$. Next line contains a single integer $$$m$$$ $$$(1 \leq m \leq...
2,600
Output a single integer — the number of pairs of paths that intersect at exactly one vertex.
standard output
PASSED
add1cfa5983b29aa99b33de5d976f269
train_110.jsonl
1613658900
You are given a tree consisting of $$$n$$$ vertices, and $$$m$$$ simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the number of pairs $$$(i, j)$$$ $$$(1 \leq i &lt; j \leq m)$$$ such that $$$path_i$$$ and $$$path_j$$$ have exactly on...
512 megabytes
/** * author: derrick20 * created: 2/20/21 10:47 PM */ import java.io.*; import java.util.*; import static java.lang.Math.*; public class PairOfPaths { static FastScanner sc = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) { N...
Java
["5\n1 2\n1 3\n1 4\n3 5\n4\n2 3\n2 4\n3 4\n3 5", "1\n3\n1 1\n1 1\n1 1", "5\n1 2\n1 3\n1 4\n3 5\n6\n2 3\n2 4\n3 4\n3 5\n1 1\n1 2"]
6 seconds
["2", "3", "7"]
NoteThe tree in the first example and paths look like this. Pairs $$$(1,4)$$$ and $$$(3,4)$$$ intersect at one vertex.In the second example all three paths contain the same single vertex, so all pairs $$$(1, 2)$$$, $$$(1, 3)$$$ and $$$(2, 3)$$$ intersect at one vertex.The third example is the same as the first example ...
Java 8
standard input
[ "combinatorics", "data structures", "dfs and similar", "dp", "trees" ]
632afd3c714e4ab34fbc474f9f99d345
First line contains a single integer $$$n$$$ $$$(1 \leq n \leq 3 \cdot 10^5)$$$. Next $$$n - 1$$$ lines describe the tree. Each line contains two integers $$$u$$$ and $$$v$$$ $$$(1 \leq u, v \leq n)$$$ describing an edge between vertices $$$u$$$ and $$$v$$$. Next line contains a single integer $$$m$$$ $$$(1 \leq m \leq...
2,600
Output a single integer — the number of pairs of paths that intersect at exactly one vertex.
standard output
PASSED
e64fece2755dc3fff13c68e2ed6f862c
train_110.jsonl
1613658900
You are given a tree consisting of $$$n$$$ vertices, and $$$m$$$ simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the number of pairs $$$(i, j)$$$ $$$(1 \leq i &lt; j \leq m)$$$ such that $$$path_i$$$ and $$$path_j$$$ have exactly on...
512 megabytes
/** * author: derrick20 * created: 2/20/21 10:47 PM */ import java.io.*; import java.util.*; import static java.lang.Math.*; public class PairOfPaths { static FastScanner sc = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) { N...
Java
["5\n1 2\n1 3\n1 4\n3 5\n4\n2 3\n2 4\n3 4\n3 5", "1\n3\n1 1\n1 1\n1 1", "5\n1 2\n1 3\n1 4\n3 5\n6\n2 3\n2 4\n3 4\n3 5\n1 1\n1 2"]
6 seconds
["2", "3", "7"]
NoteThe tree in the first example and paths look like this. Pairs $$$(1,4)$$$ and $$$(3,4)$$$ intersect at one vertex.In the second example all three paths contain the same single vertex, so all pairs $$$(1, 2)$$$, $$$(1, 3)$$$ and $$$(2, 3)$$$ intersect at one vertex.The third example is the same as the first example ...
Java 8
standard input
[ "combinatorics", "data structures", "dfs and similar", "dp", "trees" ]
632afd3c714e4ab34fbc474f9f99d345
First line contains a single integer $$$n$$$ $$$(1 \leq n \leq 3 \cdot 10^5)$$$. Next $$$n - 1$$$ lines describe the tree. Each line contains two integers $$$u$$$ and $$$v$$$ $$$(1 \leq u, v \leq n)$$$ describing an edge between vertices $$$u$$$ and $$$v$$$. Next line contains a single integer $$$m$$$ $$$(1 \leq m \leq...
2,600
Output a single integer — the number of pairs of paths that intersect at exactly one vertex.
standard output
PASSED
f2a07cce5fd669064dd68cde56b194bb
train_110.jsonl
1613658900
You are given a tree consisting of $$$n$$$ vertices, and $$$m$$$ simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the number of pairs $$$(i, j)$$$ $$$(1 \leq i &lt; j \leq m)$$$ such that $$$path_i$$$ and $$$path_j$$$ have exactly on...
512 megabytes
import java.io.*; import java.util.*; /* polyakoff */ public class Main { static FastReader in; static PrintWriter out; static Random rand = new Random(); static final int oo = (int) 1e9 + 10; static final long OO = (long) 2e18 + 10; static final int MOD = (int) 1e9 + 7; st...
Java
["5\n1 2\n1 3\n1 4\n3 5\n4\n2 3\n2 4\n3 4\n3 5", "1\n3\n1 1\n1 1\n1 1", "5\n1 2\n1 3\n1 4\n3 5\n6\n2 3\n2 4\n3 4\n3 5\n1 1\n1 2"]
6 seconds
["2", "3", "7"]
NoteThe tree in the first example and paths look like this. Pairs $$$(1,4)$$$ and $$$(3,4)$$$ intersect at one vertex.In the second example all three paths contain the same single vertex, so all pairs $$$(1, 2)$$$, $$$(1, 3)$$$ and $$$(2, 3)$$$ intersect at one vertex.The third example is the same as the first example ...
Java 8
standard input
[ "combinatorics", "data structures", "dfs and similar", "dp", "trees" ]
632afd3c714e4ab34fbc474f9f99d345
First line contains a single integer $$$n$$$ $$$(1 \leq n \leq 3 \cdot 10^5)$$$. Next $$$n - 1$$$ lines describe the tree. Each line contains two integers $$$u$$$ and $$$v$$$ $$$(1 \leq u, v \leq n)$$$ describing an edge between vertices $$$u$$$ and $$$v$$$. Next line contains a single integer $$$m$$$ $$$(1 \leq m \leq...
2,600
Output a single integer — the number of pairs of paths that intersect at exactly one vertex.
standard output
PASSED
d5199e772cdccfd451487a2cdf1faf05
train_110.jsonl
1613658900
You are given a tree consisting of $$$n$$$ vertices, and $$$m$$$ simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the number of pairs $$$(i, j)$$$ $$$(1 \leq i &lt; j \leq m)$$$ such that $$$path_i$$$ and $$$path_j$$$ have exactly on...
512 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Main { public static int inf = (int)1e9+7; public static int mod = (int)1e9+7; public static Map<Integer, List<Integer>> map; public static int[] deep; public static int[][] dp; public static int[] ldf; pu...
Java
["5\n1 2\n1 3\n1 4\n3 5\n4\n2 3\n2 4\n3 4\n3 5", "1\n3\n1 1\n1 1\n1 1", "5\n1 2\n1 3\n1 4\n3 5\n6\n2 3\n2 4\n3 4\n3 5\n1 1\n1 2"]
6 seconds
["2", "3", "7"]
NoteThe tree in the first example and paths look like this. Pairs $$$(1,4)$$$ and $$$(3,4)$$$ intersect at one vertex.In the second example all three paths contain the same single vertex, so all pairs $$$(1, 2)$$$, $$$(1, 3)$$$ and $$$(2, 3)$$$ intersect at one vertex.The third example is the same as the first example ...
Java 8
standard input
[ "combinatorics", "data structures", "dfs and similar", "dp", "trees" ]
632afd3c714e4ab34fbc474f9f99d345
First line contains a single integer $$$n$$$ $$$(1 \leq n \leq 3 \cdot 10^5)$$$. Next $$$n - 1$$$ lines describe the tree. Each line contains two integers $$$u$$$ and $$$v$$$ $$$(1 \leq u, v \leq n)$$$ describing an edge between vertices $$$u$$$ and $$$v$$$. Next line contains a single integer $$$m$$$ $$$(1 \leq m \leq...
2,600
Output a single integer — the number of pairs of paths that intersect at exactly one vertex.
standard output
PASSED
15998d631e934fdca20f36cc5c927d6e
train_110.jsonl
1613658900
You are given a tree consisting of $$$n$$$ vertices, and $$$m$$$ simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the number of pairs $$$(i, j)$$$ $$$(1 \leq i &lt; j \leq m)$$$ such that $$$path_i$$$ and $$$path_j$$$ have exactly on...
512 megabytes
//package round703; import java.io.*; import java.util.*; public class F { InputStream is; FastWriter out; String INPUT = ""; void solve() { int n = ni(); int[] from = new int[n - 1]; int[] to = new int[n - 1]; for (int i = 0; i < n - 1; i++) { from[i] = ni() - 1; to[i] = ni() - 1;...
Java
["5\n1 2\n1 3\n1 4\n3 5\n4\n2 3\n2 4\n3 4\n3 5", "1\n3\n1 1\n1 1\n1 1", "5\n1 2\n1 3\n1 4\n3 5\n6\n2 3\n2 4\n3 4\n3 5\n1 1\n1 2"]
6 seconds
["2", "3", "7"]
NoteThe tree in the first example and paths look like this. Pairs $$$(1,4)$$$ and $$$(3,4)$$$ intersect at one vertex.In the second example all three paths contain the same single vertex, so all pairs $$$(1, 2)$$$, $$$(1, 3)$$$ and $$$(2, 3)$$$ intersect at one vertex.The third example is the same as the first example ...
Java 11
standard input
[ "combinatorics", "data structures", "dfs and similar", "dp", "trees" ]
632afd3c714e4ab34fbc474f9f99d345
First line contains a single integer $$$n$$$ $$$(1 \leq n \leq 3 \cdot 10^5)$$$. Next $$$n - 1$$$ lines describe the tree. Each line contains two integers $$$u$$$ and $$$v$$$ $$$(1 \leq u, v \leq n)$$$ describing an edge between vertices $$$u$$$ and $$$v$$$. Next line contains a single integer $$$m$$$ $$$(1 \leq m \leq...
2,600
Output a single integer — the number of pairs of paths that intersect at exactly one vertex.
standard output
PASSED
62ce54e406716c4f1ff9730606a7777f
train_110.jsonl
1613658900
There are $$$n$$$ cities and $$$m$$$ bidirectional roads in the country. The roads in the country form an undirected weighted graph. The graph is not guaranteed to be connected. Each road has it's own parameter $$$w$$$. You can travel through the roads, but the government made a new law: you can only go through two roa...
512 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.math.BigInteger; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Ar...
Java
["5 6\n1 2 3\n2 3 4\n3 4 5\n4 5 6\n1 5 1\n2 4 2", "3 2\n1 2 1\n2 3 2"]
4 seconds
["0 98 49 25 114", "0 -1 9"]
NoteThe graph in the first example looks like this.In the second example the path from $$$1$$$ to $$$3$$$ goes through $$$2$$$, so the resulting payment is $$$(1 + 2)^2 = 9$$$.
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "dp", "flows", "graphs", "shortest paths" ]
abee4d188bb59d82fcf4579c7416a343
First line contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq min(\frac{n \cdot (n - 1)}{2}, 2 \cdot 10^5)$$$). Next $$$m$$$ lines each contain three integers $$$v_i$$$, $$$u_i$$$, $$$w_i$$$ ($$$1 \leq v_i, u_i \leq n$$$, $$$1 \leq w_i \leq 50$$$, $$$u_i \neq v_i$$$). It's guaranteed tha...
2,200
For every city $$$t$$$ print one integer. If there is no correct path between $$$1$$$ and $$$t$$$ output $$$-1$$$. Otherwise print out the minimum amount of money needed to travel from $$$1$$$ to $$$t$$$.
standard output
PASSED
a00858eb04e047034d951c48821d723e
train_110.jsonl
1613658900
There are $$$n$$$ cities and $$$m$$$ bidirectional roads in the country. The roads in the country form an undirected weighted graph. The graph is not guaranteed to be connected. Each road has it's own parameter $$$w$$$. You can travel through the roads, but the government made a new law: you can only go through two roa...
512 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.math.BigInteger; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Ar...
Java
["5 6\n1 2 3\n2 3 4\n3 4 5\n4 5 6\n1 5 1\n2 4 2", "3 2\n1 2 1\n2 3 2"]
4 seconds
["0 98 49 25 114", "0 -1 9"]
NoteThe graph in the first example looks like this.In the second example the path from $$$1$$$ to $$$3$$$ goes through $$$2$$$, so the resulting payment is $$$(1 + 2)^2 = 9$$$.
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "dp", "flows", "graphs", "shortest paths" ]
abee4d188bb59d82fcf4579c7416a343
First line contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq min(\frac{n \cdot (n - 1)}{2}, 2 \cdot 10^5)$$$). Next $$$m$$$ lines each contain three integers $$$v_i$$$, $$$u_i$$$, $$$w_i$$$ ($$$1 \leq v_i, u_i \leq n$$$, $$$1 \leq w_i \leq 50$$$, $$$u_i \neq v_i$$$). It's guaranteed tha...
2,200
For every city $$$t$$$ print one integer. If there is no correct path between $$$1$$$ and $$$t$$$ output $$$-1$$$. Otherwise print out the minimum amount of money needed to travel from $$$1$$$ to $$$t$$$.
standard output
PASSED
98347176ef33e44d6f02beb041115d5b
train_110.jsonl
1613658900
There are $$$n$$$ cities and $$$m$$$ bidirectional roads in the country. The roads in the country form an undirected weighted graph. The graph is not guaranteed to be connected. Each road has it's own parameter $$$w$$$. You can travel through the roads, but the government made a new law: you can only go through two roa...
512 megabytes
import java.util.*; import java.io.*; public class _1486_E { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer line = new StringTokenizer...
Java
["5 6\n1 2 3\n2 3 4\n3 4 5\n4 5 6\n1 5 1\n2 4 2", "3 2\n1 2 1\n2 3 2"]
4 seconds
["0 98 49 25 114", "0 -1 9"]
NoteThe graph in the first example looks like this.In the second example the path from $$$1$$$ to $$$3$$$ goes through $$$2$$$, so the resulting payment is $$$(1 + 2)^2 = 9$$$.
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "dp", "flows", "graphs", "shortest paths" ]
abee4d188bb59d82fcf4579c7416a343
First line contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq min(\frac{n \cdot (n - 1)}{2}, 2 \cdot 10^5)$$$). Next $$$m$$$ lines each contain three integers $$$v_i$$$, $$$u_i$$$, $$$w_i$$$ ($$$1 \leq v_i, u_i \leq n$$$, $$$1 \leq w_i \leq 50$$$, $$$u_i \neq v_i$$$). It's guaranteed tha...
2,200
For every city $$$t$$$ print one integer. If there is no correct path between $$$1$$$ and $$$t$$$ output $$$-1$$$. Otherwise print out the minimum amount of money needed to travel from $$$1$$$ to $$$t$$$.
standard output
PASSED
e9bc4e41fd918c7306bc6ab610cdd00b
train_110.jsonl
1613658900
There are $$$n$$$ cities and $$$m$$$ bidirectional roads in the country. The roads in the country form an undirected weighted graph. The graph is not guaranteed to be connected. Each road has it's own parameter $$$w$$$. You can travel through the roads, but the government made a new law: you can only go through two roa...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.PriorityQueue; import java.util.AbstractQueue; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.A...
Java
["5 6\n1 2 3\n2 3 4\n3 4 5\n4 5 6\n1 5 1\n2 4 2", "3 2\n1 2 1\n2 3 2"]
4 seconds
["0 98 49 25 114", "0 -1 9"]
NoteThe graph in the first example looks like this.In the second example the path from $$$1$$$ to $$$3$$$ goes through $$$2$$$, so the resulting payment is $$$(1 + 2)^2 = 9$$$.
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "dp", "flows", "graphs", "shortest paths" ]
abee4d188bb59d82fcf4579c7416a343
First line contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq min(\frac{n \cdot (n - 1)}{2}, 2 \cdot 10^5)$$$). Next $$$m$$$ lines each contain three integers $$$v_i$$$, $$$u_i$$$, $$$w_i$$$ ($$$1 \leq v_i, u_i \leq n$$$, $$$1 \leq w_i \leq 50$$$, $$$u_i \neq v_i$$$). It's guaranteed tha...
2,200
For every city $$$t$$$ print one integer. If there is no correct path between $$$1$$$ and $$$t$$$ output $$$-1$$$. Otherwise print out the minimum amount of money needed to travel from $$$1$$$ to $$$t$$$.
standard output
PASSED
94bd1518ed331934b9b5c554e399199f
train_110.jsonl
1613658900
There are $$$n$$$ cities and $$$m$$$ bidirectional roads in the country. The roads in the country form an undirected weighted graph. The graph is not guaranteed to be connected. Each road has it's own parameter $$$w$$$. You can travel through the roads, but the government made a new law: you can only go through two roa...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.PriorityQueue; import java.util.AbstractQueue; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.AbstractCollection; import java.util.St...
Java
["5 6\n1 2 3\n2 3 4\n3 4 5\n4 5 6\n1 5 1\n2 4 2", "3 2\n1 2 1\n2 3 2"]
4 seconds
["0 98 49 25 114", "0 -1 9"]
NoteThe graph in the first example looks like this.In the second example the path from $$$1$$$ to $$$3$$$ goes through $$$2$$$, so the resulting payment is $$$(1 + 2)^2 = 9$$$.
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "dp", "flows", "graphs", "shortest paths" ]
abee4d188bb59d82fcf4579c7416a343
First line contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq min(\frac{n \cdot (n - 1)}{2}, 2 \cdot 10^5)$$$). Next $$$m$$$ lines each contain three integers $$$v_i$$$, $$$u_i$$$, $$$w_i$$$ ($$$1 \leq v_i, u_i \leq n$$$, $$$1 \leq w_i \leq 50$$$, $$$u_i \neq v_i$$$). It's guaranteed tha...
2,200
For every city $$$t$$$ print one integer. If there is no correct path between $$$1$$$ and $$$t$$$ output $$$-1$$$. Otherwise print out the minimum amount of money needed to travel from $$$1$$$ to $$$t$$$.
standard output
PASSED
be86665dfb1dabec58b173eb020a067b
train_110.jsonl
1613658900
There are $$$n$$$ cities and $$$m$$$ bidirectional roads in the country. The roads in the country form an undirected weighted graph. The graph is not guaranteed to be connected. Each road has it's own parameter $$$w$$$. You can travel through the roads, but the government made a new law: you can only go through two roa...
512 megabytes
// copied import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.PriorityQueue; import java.util.StringTokenizer; public class Main { static final int N = (int) (2e5 + 11), INF = (int) (1e9...
Java
["5 6\n1 2 3\n2 3 4\n3 4 5\n4 5 6\n1 5 1\n2 4 2", "3 2\n1 2 1\n2 3 2"]
4 seconds
["0 98 49 25 114", "0 -1 9"]
NoteThe graph in the first example looks like this.In the second example the path from $$$1$$$ to $$$3$$$ goes through $$$2$$$, so the resulting payment is $$$(1 + 2)^2 = 9$$$.
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "dp", "flows", "graphs", "shortest paths" ]
abee4d188bb59d82fcf4579c7416a343
First line contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq min(\frac{n \cdot (n - 1)}{2}, 2 \cdot 10^5)$$$). Next $$$m$$$ lines each contain three integers $$$v_i$$$, $$$u_i$$$, $$$w_i$$$ ($$$1 \leq v_i, u_i \leq n$$$, $$$1 \leq w_i \leq 50$$$, $$$u_i \neq v_i$$$). It's guaranteed tha...
2,200
For every city $$$t$$$ print one integer. If there is no correct path between $$$1$$$ and $$$t$$$ output $$$-1$$$. Otherwise print out the minimum amount of money needed to travel from $$$1$$$ to $$$t$$$.
standard output
PASSED
7e3426a56f9fa7c5fb2bb3ef7d707e91
train_110.jsonl
1613658900
There are $$$n$$$ cities and $$$m$$$ bidirectional roads in the country. The roads in the country form an undirected weighted graph. The graph is not guaranteed to be connected. Each road has it's own parameter $$$w$$$. You can travel through the roads, but the government made a new law: you can only go through two roa...
512 megabytes
import java.util.*; import java.io.*; public class A{ public static void main(String [] args)throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); FastReader sc=new FastReader(); PrintWriter pw=new PrintWriter(System.out); int test=1...
Java
["5 6\n1 2 3\n2 3 4\n3 4 5\n4 5 6\n1 5 1\n2 4 2", "3 2\n1 2 1\n2 3 2"]
4 seconds
["0 98 49 25 114", "0 -1 9"]
NoteThe graph in the first example looks like this.In the second example the path from $$$1$$$ to $$$3$$$ goes through $$$2$$$, so the resulting payment is $$$(1 + 2)^2 = 9$$$.
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "dp", "flows", "graphs", "shortest paths" ]
abee4d188bb59d82fcf4579c7416a343
First line contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq min(\frac{n \cdot (n - 1)}{2}, 2 \cdot 10^5)$$$). Next $$$m$$$ lines each contain three integers $$$v_i$$$, $$$u_i$$$, $$$w_i$$$ ($$$1 \leq v_i, u_i \leq n$$$, $$$1 \leq w_i \leq 50$$$, $$$u_i \neq v_i$$$). It's guaranteed tha...
2,200
For every city $$$t$$$ print one integer. If there is no correct path between $$$1$$$ and $$$t$$$ output $$$-1$$$. Otherwise print out the minimum amount of money needed to travel from $$$1$$$ to $$$t$$$.
standard output
PASSED
a3e2982a93a08b7b6adee90469308b5a
train_110.jsonl
1613658900
There are $$$n$$$ cities and $$$m$$$ bidirectional roads in the country. The roads in the country form an undirected weighted graph. The graph is not guaranteed to be connected. Each road has it's own parameter $$$w$$$. You can travel through the roads, but the government made a new law: you can only go through two roa...
512 megabytes
import java.util.*; import java.io.*; public class A{ public static void main(String [] args)throws IOException{ // BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); FastReader sc=new FastReader(); PrintWriter pw=new PrintWriter(System.out); int tes...
Java
["5 6\n1 2 3\n2 3 4\n3 4 5\n4 5 6\n1 5 1\n2 4 2", "3 2\n1 2 1\n2 3 2"]
4 seconds
["0 98 49 25 114", "0 -1 9"]
NoteThe graph in the first example looks like this.In the second example the path from $$$1$$$ to $$$3$$$ goes through $$$2$$$, so the resulting payment is $$$(1 + 2)^2 = 9$$$.
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "dp", "flows", "graphs", "shortest paths" ]
abee4d188bb59d82fcf4579c7416a343
First line contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq min(\frac{n \cdot (n - 1)}{2}, 2 \cdot 10^5)$$$). Next $$$m$$$ lines each contain three integers $$$v_i$$$, $$$u_i$$$, $$$w_i$$$ ($$$1 \leq v_i, u_i \leq n$$$, $$$1 \leq w_i \leq 50$$$, $$$u_i \neq v_i$$$). It's guaranteed tha...
2,200
For every city $$$t$$$ print one integer. If there is no correct path between $$$1$$$ and $$$t$$$ output $$$-1$$$. Otherwise print out the minimum amount of money needed to travel from $$$1$$$ to $$$t$$$.
standard output
PASSED
6b39e638709d39adca0ba37d7d229293
train_110.jsonl
1613658900
There are $$$n$$$ cities and $$$m$$$ bidirectional roads in the country. The roads in the country form an undirected weighted graph. The graph is not guaranteed to be connected. Each road has it's own parameter $$$w$$$. You can travel through the roads, but the government made a new law: you can only go through two roa...
512 megabytes
import java.io.*; import java.util.*; public class CF703E { static final int N = (int)(2e5 + 11), INF = (int)(1e9 + 11); static int n, m, v, u, w; static ArrayList< int[] > g[] = new ArrayList[N]; static int[][] d; static PriorityQueue<Node> pq; public static void main (String[] args) throws IOExce...
Java
["5 6\n1 2 3\n2 3 4\n3 4 5\n4 5 6\n1 5 1\n2 4 2", "3 2\n1 2 1\n2 3 2"]
4 seconds
["0 98 49 25 114", "0 -1 9"]
NoteThe graph in the first example looks like this.In the second example the path from $$$1$$$ to $$$3$$$ goes through $$$2$$$, so the resulting payment is $$$(1 + 2)^2 = 9$$$.
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "dp", "flows", "graphs", "shortest paths" ]
abee4d188bb59d82fcf4579c7416a343
First line contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq min(\frac{n \cdot (n - 1)}{2}, 2 \cdot 10^5)$$$). Next $$$m$$$ lines each contain three integers $$$v_i$$$, $$$u_i$$$, $$$w_i$$$ ($$$1 \leq v_i, u_i \leq n$$$, $$$1 \leq w_i \leq 50$$$, $$$u_i \neq v_i$$$). It's guaranteed tha...
2,200
For every city $$$t$$$ print one integer. If there is no correct path between $$$1$$$ and $$$t$$$ output $$$-1$$$. Otherwise print out the minimum amount of money needed to travel from $$$1$$$ to $$$t$$$.
standard output