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
f185fa29d22ea073af0e26359f51fb13
train_002.jsonl
1581257100
Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more a...
256 megabytes
import java.io.*; import java.util.*; import java.util.ArrayList; import java.util.Scanner; public class P1299A { public static void main(String[] args) { InputReader sc = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); int n = sc.nextInt(); BitCount ...
Java
["4\n4 0 11 6", "1\n13"]
1 second
["11 6 4 0", "13"]
NoteIn the first testcase, value of the array $$$[11, 6, 4, 0]$$$ is $$$f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9$$$.$$$[11, 4, 0, 6]$$$ is also a valid answer.
Java 11
standard input
[ "greedy", "math", "brute force" ]
14fd47f6f0fcbdb16dbd73dcca8a782f
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.
1,500
Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.
standard output
PASSED
ef762fb9c6514718984510c155dccc53
train_002.jsonl
1581257100
Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more a...
256 megabytes
import java.io.*; import java.util.*; import java.util.ArrayList; import java.util.Scanner; public class P1299A { public static void main(String[] args) { InputReader sc = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); int n = sc.nextInt(); BitCount ...
Java
["4\n4 0 11 6", "1\n13"]
1 second
["11 6 4 0", "13"]
NoteIn the first testcase, value of the array $$$[11, 6, 4, 0]$$$ is $$$f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9$$$.$$$[11, 4, 0, 6]$$$ is also a valid answer.
Java 11
standard input
[ "greedy", "math", "brute force" ]
14fd47f6f0fcbdb16dbd73dcca8a782f
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.
1,500
Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.
standard output
PASSED
5e9f3d04ba9b1d69241d527998854f73
train_002.jsonl
1581257100
Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more a...
256 megabytes
import java.io.*; import java.util.*; import java.util.ArrayList; import java.util.Scanner; public class P1299A { public static void main(String[] args) { InputReader sc = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); int n = sc.nextInt(); BitCount [...
Java
["4\n4 0 11 6", "1\n13"]
1 second
["11 6 4 0", "13"]
NoteIn the first testcase, value of the array $$$[11, 6, 4, 0]$$$ is $$$f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9$$$.$$$[11, 4, 0, 6]$$$ is also a valid answer.
Java 11
standard input
[ "greedy", "math", "brute force" ]
14fd47f6f0fcbdb16dbd73dcca8a782f
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.
1,500
Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.
standard output
PASSED
b036a97025e9f9ddba22c05f82a09f63
train_002.jsonl
1581257100
Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more a...
256 megabytes
import java.util.*; import java.util.ArrayList; import java.util.Scanner; public class P1299A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); BitCount [] bitCount = new BitCount[65]; List<Integer> arr = new ArrayList<>(); ...
Java
["4\n4 0 11 6", "1\n13"]
1 second
["11 6 4 0", "13"]
NoteIn the first testcase, value of the array $$$[11, 6, 4, 0]$$$ is $$$f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9$$$.$$$[11, 4, 0, 6]$$$ is also a valid answer.
Java 11
standard input
[ "greedy", "math", "brute force" ]
14fd47f6f0fcbdb16dbd73dcca8a782f
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.
1,500
Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.
standard output
PASSED
d1814c83a299eb5b0dae5eaaf3140b37
train_002.jsonl
1581257100
Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more a...
256 megabytes
import java.io.*; import java.util.*; import java.util.ArrayList; import java.util.Scanner; public class P1299A { public static void main(String[] args) { //System.out.print((1<<2)); InputReader sc = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); int ...
Java
["4\n4 0 11 6", "1\n13"]
1 second
["11 6 4 0", "13"]
NoteIn the first testcase, value of the array $$$[11, 6, 4, 0]$$$ is $$$f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9$$$.$$$[11, 4, 0, 6]$$$ is also a valid answer.
Java 11
standard input
[ "greedy", "math", "brute force" ]
14fd47f6f0fcbdb16dbd73dcca8a782f
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.
1,500
Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.
standard output
PASSED
79a83a6e0f4a977406eac96d90efc4c9
train_002.jsonl
1581257100
Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more a...
256 megabytes
import java.util.*; import java.util.ArrayList; import java.util.Scanner; public class P1299A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); BitCount [] bitCount = new BitCount[65]; List<Integer> arr = new ArrayList<>(); ...
Java
["4\n4 0 11 6", "1\n13"]
1 second
["11 6 4 0", "13"]
NoteIn the first testcase, value of the array $$$[11, 6, 4, 0]$$$ is $$$f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9$$$.$$$[11, 4, 0, 6]$$$ is also a valid answer.
Java 11
standard input
[ "greedy", "math", "brute force" ]
14fd47f6f0fcbdb16dbd73dcca8a782f
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.
1,500
Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.
standard output
PASSED
3bd954cb98e1e8a965bcc1e0b3a89d41
train_002.jsonl
1581257100
Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more a...
256 megabytes
import java.io.*; import java.util.*; import java.util.ArrayList; import java.util.Scanner; public class P1299A { public static void main(String[] args) { InputReader sc = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); int n = sc.nextInt(); BitCount ...
Java
["4\n4 0 11 6", "1\n13"]
1 second
["11 6 4 0", "13"]
NoteIn the first testcase, value of the array $$$[11, 6, 4, 0]$$$ is $$$f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9$$$.$$$[11, 4, 0, 6]$$$ is also a valid answer.
Java 11
standard input
[ "greedy", "math", "brute force" ]
14fd47f6f0fcbdb16dbd73dcca8a782f
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.
1,500
Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.
standard output
PASSED
1ef372cf748bb6ad5853cfbbbfdd6f6b
train_002.jsonl
1581257100
Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more a...
256 megabytes
import java.io.*; import java.util.*; import java.util.ArrayList; import java.util.Scanner; public class P1299A { public static void main(String[] args) { //System.out.print((1<<2)); InputReader sc = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); int ...
Java
["4\n4 0 11 6", "1\n13"]
1 second
["11 6 4 0", "13"]
NoteIn the first testcase, value of the array $$$[11, 6, 4, 0]$$$ is $$$f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9$$$.$$$[11, 4, 0, 6]$$$ is also a valid answer.
Java 11
standard input
[ "greedy", "math", "brute force" ]
14fd47f6f0fcbdb16dbd73dcca8a782f
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.
1,500
Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.
standard output
PASSED
3889c23a4b205bf90716153d7ef6701e
train_002.jsonl
1581257100
Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more a...
256 megabytes
import javax.swing.*; import java.awt.desktop.SystemSleepEvent; import java.util.*; import java.io.*; public class Main { public static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReade...
Java
["4\n4 0 11 6", "1\n13"]
1 second
["11 6 4 0", "13"]
NoteIn the first testcase, value of the array $$$[11, 6, 4, 0]$$$ is $$$f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9$$$.$$$[11, 4, 0, 6]$$$ is also a valid answer.
Java 11
standard input
[ "greedy", "math", "brute force" ]
14fd47f6f0fcbdb16dbd73dcca8a782f
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.
1,500
Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.
standard output
PASSED
a9ef5dfbcbefdb8a1cce7f7c09840562
train_002.jsonl
1581257100
Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more a...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.File; impo...
Java
["4\n4 0 11 6", "1\n13"]
1 second
["11 6 4 0", "13"]
NoteIn the first testcase, value of the array $$$[11, 6, 4, 0]$$$ is $$$f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9$$$.$$$[11, 4, 0, 6]$$$ is also a valid answer.
Java 11
standard input
[ "greedy", "math", "brute force" ]
14fd47f6f0fcbdb16dbd73dcca8a782f
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.
1,500
Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.
standard output
PASSED
d2fd05296d016eb90e17c27a06a7827f
train_002.jsonl
1581257100
Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more a...
256 megabytes
import java.util.*; import java.io.*; public class AnuIsBack{ public static void main(String[] args) throws IOException{ Reader in = new Reader(); int n = in.nextInt(); int[]a=new int[100005],b=new int[100005],l=new int[100005],r=new int[100005]; for (int i = 1; i <= n; i++) { ...
Java
["4\n4 0 11 6", "1\n13"]
1 second
["11 6 4 0", "13"]
NoteIn the first testcase, value of the array $$$[11, 6, 4, 0]$$$ is $$$f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9$$$.$$$[11, 4, 0, 6]$$$ is also a valid answer.
Java 11
standard input
[ "greedy", "math", "brute force" ]
14fd47f6f0fcbdb16dbd73dcca8a782f
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.
1,500
Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.
standard output
PASSED
21e9b2e502bf3c1106b878fa7481c164
train_002.jsonl
1581257100
Anu has created her own function $$$f$$$: $$$f(x, y) = (x | y) - y$$$ where $$$|$$$ denotes the bitwise OR operation. For example, $$$f(11, 6) = (11|6) - 6 = 15 - 6 = 9$$$. It can be proved that for any nonnegative numbers $$$x$$$ and $$$y$$$ value of $$$f(x, y)$$$ is also nonnegative. She would like to research more a...
256 megabytes
import java.util.Scanner; public class Anu{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] A = new int[n]; boolean[] check = new boolean[30]; int[] store = new int[30]; boolean[] check2 = new boolean[30]; ...
Java
["4\n4 0 11 6", "1\n13"]
1 second
["11 6 4 0", "13"]
NoteIn the first testcase, value of the array $$$[11, 6, 4, 0]$$$ is $$$f(f(f(11, 6), 4), 0) = f(f(9, 4), 0) = f(9, 0) = 9$$$.$$$[11, 4, 0, 6]$$$ is also a valid answer.
Java 11
standard input
[ "greedy", "math", "brute force" ]
14fd47f6f0fcbdb16dbd73dcca8a782f
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). Elements of the array are not guaranteed to be different.
1,500
Output $$$n$$$ integers, the reordering of the array with maximum value. If there are multiple answers, print any.
standard output
PASSED
49b5624f28ce0560f840a8078cff4ec9
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
// -*- coding: utf-8 -*- //import java.awt.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream; if (args.length > 0 && args[0].equals("devTesting")) { try { inputStream = new FileIn...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
5206519817e48cbab8a3cf39c89100b1
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.util.*; import java.io.*; public class Main extends Reader { public static void main(String[] args) throws IOException { int n = ni(), m = ni(); int a[] = new int[n]; int aa[] = new int[n]; int bb[] = new int[m]; long b[] = new long[m]; Map<Integer, LinkedList<Integer>> ...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
1585661a8288f751e261aaf26f4d7a91
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.*; import java.util.*; public class E { public static void solution(BufferedReader reader, PrintWriter writer) throws IOException { In in = new In(reader); Out out = new Out(writer); int n = in.nextInt(), m = in.nextInt(); HashMap<Integer, LinkedList<Integ...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
07e4fcd193c553854bc190c3f85ab1ea
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.*; import java.util.*; public class E { public static void solution(BufferedReader reader, PrintWriter out) throws IOException { In in = new In(reader); int n = in.nextInt(), m = in.nextInt(); HashMap<Integer, LinkedList<Integer>> comp = new HashMap<Integer, Linke...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
b3b8663f71491e0996bfad64923597eb
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.*; import java.util.*; public class E { public static void solution(BufferedReader reader, PrintWriter writer) throws IOException { In in = new In(reader); Out out = new Out(writer); int n = in.nextInt(), m = in.nextInt(); HashMap<Integer, LinkedList<Integ...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
4aa2754dd29e200219e615323d3c44c1
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.*; import java.util.*; public class E { public static void solution(BufferedReader reader, PrintWriter out) throws IOException { In in = new In(reader); int n = in.nextInt(), m = in.nextInt(); HashMap<Integer, LinkedList<Integer>> comp = new HashMap<Integer, Linke...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
25dbb683039816d543266484e42da123
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.*; import java.util.*; public class E { public static void solution(BufferedReader reader, PrintWriter out) throws IOException { In in = new In(reader); int n = in.nextInt(), m = in.nextInt(); HashMap<Integer, LinkedList<Integer>> comp = new HashMap<Integer, Linke...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
7d8af37f9641afc5aaab1369f16620a0
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.*; import java.util.*; public class E { public static void solution(BufferedReader reader, PrintWriter out) throws IOException { In in = new In(reader); int n = in.nextInt(), m = in.nextInt(); HashMap<Integer, LinkedList<Integer>> comp = new HashMap<Integer, Linke...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
59c516c688652310fd520d5e79668c4d
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.*; import java.util.*; /** * * @author Sourav Kumar Paul (spaul100) * NIT Silchar */ public class SolveE { public static Reader in; public static PrintWriter out; public static long mod = 1000000007; public static long inf = 100000000000000000l; public static long fac[],inv...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
cdfe1239857edb26ac78982efd5dd54e
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.PriorityQueue; import java.util.StringTokenizer; public class E { public ...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
f85f2b6b8a2faaec5254751f71faa5ea
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; @SuppressWarnings("unchecked") public class P732E { public void run() throws Exception { int n = nextInt(), m = nextInt(); Map<Integer, Deque<Integer>> comp = new HashMap(n); for (int i = 0; i < n; i++) { int p =...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
a47c73491b8936f842516ad4306b867a
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.*; import java.util.*; public class TaskE { static InputReader in; static PrintWriter out; public static void main(String[] args) throws FileNotFoundException { InputStream inputStream = System.in; //FileInputStream inputStream = new FileInputStream("input.txt"); OutputStream outputStrea...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
c619c8d34c94a9960f09e80c73c2a271
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; public class TestClass { private static InputStream stream; private static byte[] buf = new byte[1024]; private static int curChar; private static int numChars; private static Space...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
a09c09a45012cb3051745075f6365928
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper plug-in ...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
85bb1965ffda4b779ba89fed951a9f00
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper plug-in ...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
60acf64e620c8138d018161a704c4f6b
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper plug-in ...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
c97956a96ea339fb646b1d94047b525a
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.Random; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Bui...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
b044101c44b6e6eb05ba163bf674c7bf
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper plug-in ...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
d85bd46a9692043c197bfce7ce20e1f3
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.String...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
7c50d21a306dd7612f9b436ca07a72e4
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Queue; import java.u...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
5cc253d6e0d9bdef20b7ebdd2224be90
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.NoSuchElementException; public class E { private static class Task { void solve(FastScanner in, PrintWriter out) throws Exception { long start = Syste...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
3ee0c4e2e4e53356d65f03ca2d0c5adc
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Map; import ja...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
84433bed0ad599bb3e82eb9aa2956c46
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.NoSuchElementException; /* _ooOoo_ o8888888o 88" . "88 (| -_- |) O\ = /...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
c56140cdcae2aa4b5b52612def86c68c
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.*; import java.util.*; import java.util.stream.IntStream; import static java.lang.Math.*; public class Main { FastScanner in; PrintWriter out; static final String FILE = ""; void solve() { int n = in.nextInt(), m = in.nextInt(); int[] p = new int[n]; for (int i...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
f0e289c03aabbf0271cb765020adc038
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
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.StringTokenizer; /** * @author Don Li */ public class Sockets { void solve() { int n = in.nextInt(), m = in.nextInt(); int[] p = new i...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
72332b7613550b622c86ad810745835e
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.Comparator; import java.io.InputStream...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
627d86ca5ea9ef4b4736a25d5ea6f0bb
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.io.BufferedReader; import java.util.regex.Pattern; import j...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
c2a94f51c7e3c70b5da051d7378e9ff6
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.*; import java.util.*; public class CF732E { static class X { int p, j, a; X(int p, int j, int a) { this.p = p; this.j = j; this.a = a; } } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTo...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
8fa32ca4691fe397ed53f7dfae0b838f
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.io.IOException; import java.util.ArrayDeque; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Queue; public class Sockets { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt(); int M = ...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
5c866a7d84365f01f5882ca57755d153
train_002.jsonl
1476714900
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement for all the participants workstations.There are n computers for participants, the i-th of which has power equal...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public class Main { @SuppressWarnings("unchecked") public static void main (String[] args) throws java.lang.Exception { //BufferedReader in=new BufferedReader(new FileReader(".\\mmk\\test\\A-small-attempt0.in")); //PrintWriter out=new Print...
Java
["2 2\n1 1\n2 2", "2 1\n2 100\n99"]
2 seconds
["2 2\n1 1\n1 2", "1 6\n6\n1 0"]
null
Java 8
standard input
[ "sortings", "greedy" ]
0a687ec4e1411750e33cc3670a614574
The first line contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of computers and the number of sockets. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 109) — the powers of the computers. The third line contains m integers s1, s2, ..., sm (1 ≤ si ≤ 109) — the power of the sockets.
2,100
In the first line print two numbers c and u — the maximum number of computers which can at the same time be connected to electricity and the minimum number of adapters needed to connect c computers. In the second line print m integers a1, a2, ..., am (0 ≤ ai ≤ 109), where ai equals the number of adapters orginizers nee...
standard output
PASSED
a85e60107195797024e19e20167bfc89
train_002.jsonl
1308236400
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.To solve the crossword you should cross out all repeated letters in rows and columns. In other words, a letter ...
256 megabytes
import java.io.*; import java.util.*; public final class african_puzzle { static Scanner sc=new Scanner(System.in); static PrintWriter out=new PrintWriter(System.out); public static void main(String args[]) throws Exception { int n=sc.nextInt(),m=sc.nextInt(); char[][] a=new char[n][m]; int[][] v1=new int[n...
Java
["3 3\ncba\nbcd\ncbc", "5 5\nfcofd\nooedo\nafaoa\nrdcdf\neofsf"]
2 seconds
["abcd", "codeforces"]
null
Java 7
standard input
[ "implementation", "strings" ]
9c90974a0bb860a5e180760042fd5045
The first line contains two integers n and m (1 ≤ n, m ≤ 100). Next n lines contain m lowercase Latin letters each. That is the crossword grid.
1,100
Print the encrypted word on a single line. It is guaranteed that the answer consists of at least one letter.
standard output
PASSED
5d0fa34945d9c227000e5b7ab23e4387
train_002.jsonl
1308236400
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.To solve the crossword you should cross out all repeated letters in rows and columns. In other words, a letter ...
256 megabytes
import java.util.Scanner; public class AfricanCrossword { public static void main(String[] args) { int n,m; Scanner sc=new Scanner(System.in); n=sc.nextInt(); m=sc.nextInt(); String a=""; int count; String [] word=new String[n]; char [][] wor=new char...
Java
["3 3\ncba\nbcd\ncbc", "5 5\nfcofd\nooedo\nafaoa\nrdcdf\neofsf"]
2 seconds
["abcd", "codeforces"]
null
Java 7
standard input
[ "implementation", "strings" ]
9c90974a0bb860a5e180760042fd5045
The first line contains two integers n and m (1 ≤ n, m ≤ 100). Next n lines contain m lowercase Latin letters each. That is the crossword grid.
1,100
Print the encrypted word on a single line. It is guaranteed that the answer consists of at least one letter.
standard output
PASSED
fcd102d8b5256a56b853b1b05c30d775
train_002.jsonl
1308236400
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.To solve the crossword you should cross out all repeated letters in rows and columns. In other words, a letter ...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import ja...
Java
["3 3\ncba\nbcd\ncbc", "5 5\nfcofd\nooedo\nafaoa\nrdcdf\neofsf"]
2 seconds
["abcd", "codeforces"]
null
Java 7
standard input
[ "implementation", "strings" ]
9c90974a0bb860a5e180760042fd5045
The first line contains two integers n and m (1 ≤ n, m ≤ 100). Next n lines contain m lowercase Latin letters each. That is the crossword grid.
1,100
Print the encrypted word on a single line. It is guaranteed that the answer consists of at least one letter.
standard output
PASSED
685455a0b032564200f3684be8705eff
train_002.jsonl
1308236400
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.To solve the crossword you should cross out all repeated letters in rows and columns. In other words, a letter ...
256 megabytes
import java.util.Scanner; public class problem90B { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); sc.nextLine(); char[][] arr = new char[n][m]; for(int i=0;i<n;i++){ String str = sc.nextLin...
Java
["3 3\ncba\nbcd\ncbc", "5 5\nfcofd\nooedo\nafaoa\nrdcdf\neofsf"]
2 seconds
["abcd", "codeforces"]
null
Java 7
standard input
[ "implementation", "strings" ]
9c90974a0bb860a5e180760042fd5045
The first line contains two integers n and m (1 ≤ n, m ≤ 100). Next n lines contain m lowercase Latin letters each. That is the crossword grid.
1,100
Print the encrypted word on a single line. It is guaranteed that the answer consists of at least one letter.
standard output
PASSED
604895b45652404ad4134d2f3f27baa4
train_002.jsonl
1308236400
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.To solve the crossword you should cross out all repeated letters in rows and columns. In other words, a letter ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Solution { private BufferedReader in; private PrintWriter out; private StringTokenizer st; public String next() throws Exception { if (st == null || !st.hasMoreElements()) { st = new StringTokenizer(in.readLine...
Java
["3 3\ncba\nbcd\ncbc", "5 5\nfcofd\nooedo\nafaoa\nrdcdf\neofsf"]
2 seconds
["abcd", "codeforces"]
null
Java 7
standard input
[ "implementation", "strings" ]
9c90974a0bb860a5e180760042fd5045
The first line contains two integers n and m (1 ≤ n, m ≤ 100). Next n lines contain m lowercase Latin letters each. That is the crossword grid.
1,100
Print the encrypted word on a single line. It is guaranteed that the answer consists of at least one letter.
standard output
PASSED
2e02fd5e28c06f470ccf2bd6e78e035f
train_002.jsonl
1308236400
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.To solve the crossword you should cross out all repeated letters in rows and columns. In other words, a letter ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author nas...
Java
["3 3\ncba\nbcd\ncbc", "5 5\nfcofd\nooedo\nafaoa\nrdcdf\neofsf"]
2 seconds
["abcd", "codeforces"]
null
Java 7
standard input
[ "implementation", "strings" ]
9c90974a0bb860a5e180760042fd5045
The first line contains two integers n and m (1 ≤ n, m ≤ 100). Next n lines contain m lowercase Latin letters each. That is the crossword grid.
1,100
Print the encrypted word on a single line. It is guaranteed that the answer consists of at least one letter.
standard output
PASSED
eb29b41fea57943988d93834e4e28a17
train_002.jsonl
1308236400
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.To solve the crossword you should cross out all repeated letters in rows and columns. In other words, a letter ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException{ BufferedReader bfr= new BufferedReader(new InputStreamReader(System.in)); String[] init= bfr.readLine().split(" "); int x=Integer.pa...
Java
["3 3\ncba\nbcd\ncbc", "5 5\nfcofd\nooedo\nafaoa\nrdcdf\neofsf"]
2 seconds
["abcd", "codeforces"]
null
Java 7
standard input
[ "implementation", "strings" ]
9c90974a0bb860a5e180760042fd5045
The first line contains two integers n and m (1 ≤ n, m ≤ 100). Next n lines contain m lowercase Latin letters each. That is the crossword grid.
1,100
Print the encrypted word on a single line. It is guaranteed that the answer consists of at least one letter.
standard output
PASSED
a006a27411d0bc77b60b68d76f421b16
train_002.jsonl
1490625300
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class D { public void solve(InputReader in, PrintWriter out) { long n, q; n = ...
Java
["15 2\n4\nUURL\n8\nLRLLLLLLLL"]
3 seconds
["10\n5"]
null
Java 8
standard input
[ "bitmasks", "trees" ]
dc35bdf56bb0ac341895e543b001b801
The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any chara...
1,900
Print q numbers, i-th number must be the answer to the i-th query.
standard output
PASSED
59c0842e0f1185a7e52bb0770c79e5d9
train_002.jsonl
1490625300
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["15 2\n4\nUURL\n8\nLRLLLLLLLL"]
3 seconds
["10\n5"]
null
Java 8
standard input
[ "bitmasks", "trees" ]
dc35bdf56bb0ac341895e543b001b801
The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any chara...
1,900
Print q numbers, i-th number must be the answer to the i-th query.
standard output
PASSED
a1601a644065683e4a6e203acd30d241
train_002.jsonl
1490625300
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n ...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static int findHeight(long n){ int ans = 0; while(n>0){ n>>=1; ans++; } return ans; } public static long[] find(long v,int height, long val){ long temp = val; ...
Java
["15 2\n4\nUURL\n8\nLRLLLLLLLL"]
3 seconds
["10\n5"]
null
Java 8
standard input
[ "bitmasks", "trees" ]
dc35bdf56bb0ac341895e543b001b801
The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any chara...
1,900
Print q numbers, i-th number must be the answer to the i-th query.
standard output
PASSED
86355663766f1f400a556810f3f01311
train_002.jsonl
1490625300
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n ...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; public class D { public D() { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); long n = sc.nextLong(); int depth = (int) (Math.log(n + 1) / Math.log(2)); long[] arr = new long[depth + 2]; arr[0] = 1; for (int i = 1...
Java
["15 2\n4\nUURL\n8\nLRLLLLLLLL"]
3 seconds
["10\n5"]
null
Java 8
standard input
[ "bitmasks", "trees" ]
dc35bdf56bb0ac341895e543b001b801
The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any chara...
1,900
Print q numbers, i-th number must be the answer to the i-th query.
standard output
PASSED
0e7452c85f7d8957e5b85bb9bd063ba1
train_002.jsonl
1490625300
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashSet; import java.util.StringTokenizer; public class D { public static void main(String[] args){ FastScanner scan = new FastScanner(); PrintWriter out = new PrintWriter(Sys...
Java
["15 2\n4\nUURL\n8\nLRLLLLLLLL"]
3 seconds
["10\n5"]
null
Java 8
standard input
[ "bitmasks", "trees" ]
dc35bdf56bb0ac341895e543b001b801
The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any chara...
1,900
Print q numbers, i-th number must be the answer to the i-th query.
standard output
PASSED
f28351853e35adeadb72d4d10ce2fe33
train_002.jsonl
1490625300
T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So n is a number such that n ...
256 megabytes
import java.util.*; public class a{ public static void main(String[] args) { Scanner in=new Scanner(System.in); long n=in.nextLong(); long q=in.nextLong(); long root=(n/2)+1; while(q--!=0){ long x=in.nextLong(); String str=in.next(); for(int i=0;i<str.length();i++){ // System.out.println("x "...
Java
["15 2\n4\nUURL\n8\nLRLLLLLLLL"]
3 seconds
["10\n5"]
null
Java 8
standard input
[ "bitmasks", "trees" ]
dc35bdf56bb0ac341895e543b001b801
The first line contains two integer numbers n and q (1 ≤ n ≤ 1018, q ≥ 1). n is such that n + 1 is a power of 2. The next 2q lines represent queries; each query consists of two consecutive lines. The first of these two lines contains ui (1 ≤ ui ≤ n), the second contains non-empty string si. si doesn't contain any chara...
1,900
Print q numbers, i-th number must be the answer to the i-th query.
standard output
PASSED
8cbf3e1f448daf99e3b7b75be3e60074
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int k=input.nextInt(); ArrayList<Integer>arr=new ArrayList<Integer>(); for(int i=0;i<n;i++) ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
cbf89cde570f9f750a9e0707dff6834b
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int k=input.nextInt(); int []arr=new int[n]; for(int i=0;i<n;i++) arr[i]=input.nextInt(); k--; ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
f75e273900e0b5616604b4047c2938c3
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int k=input.nextInt(); ArrayList<Integer>arr=new ArrayList<Integer>(); for(int i=0;i<n;i++) ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
a3c4579d6bd44820d0dc1234081418b3
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; import java.util.*; import java.util.Arrays; import java.lang.*; public class Amr { public static void main(String[] args) { Scanner input= new Scanner(System.in); int k,res,m; k=input.nextInt(); m=input.nextInt(); int c[]...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
f89670bab56898faedfc01b694af4b2c
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; import java.util.*; import java.util.Arrays; import java.lang.*; public class Amr { public static void main(String[] args) { Scanner input= new Scanner(System.in); int k,res,m; k=input.nextInt(); m=input.nextInt(); int c[]...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
29d304b632c6be846eb80a516a3c6583
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class ShooshunsAndSequence { public static void main(String []args)throws IOException { BufferedReader br=new ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
354fb0888a186a7119bf1e70479b8cbb
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.io.*; import java.util.*; 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(outputStream); Tas...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
864a704bcd9680be46f47b65435f1731
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(),m = input.nextInt(); int a[] = new int[n]; for(int i = 0 ; i < n;i++){ a[i] = input.nextInt(); } int i = 0; for(i = a.length - 1 ; i > 0;i--){ ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
aa27be01a82dbbd1c7e5fe1c91c921cd
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; public class JavaApplication6 { public static void main(String[] args) { // TODO code application logic here Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt() - 1; int[] a = new int[n]; for (int i = 0; i < n; i...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
d26d7a7fcf664e9c40cbbdc914fadda1
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Sunits789 */ public class M...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
4d3f80ed45fd70af49bb098272f5a38a
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.io.FileNotFoundException; import java.io.InputStreamReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.FileReader; import java.io.BufferedWriter; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.File; import java.io.Wri...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
eafcd4552b42a2e9fdf8fbde486d2a75
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; public class A_222_Shooshuns_and_Sequence { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); boolean f = true; int a[] = new int[n + 1]; for (int i = 1; i <= n; i++) { a[i] = sc.nextInt(); } for (int ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
6dac03d4a1dea0207d100775ac9a2048
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; public class ShooshunsAndSequence { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n, k, counter = 0, counterz = 0, b = 0, c = 0; boolean flag = false; n = sc.nextInt(); k = sc.nextInt(); int[] a = new i...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
6991c5c1d73b801291f8fd253eedbe5e
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; public class test{ public static long[] arr = new long[200010]; public static void main(String[] args){ Scanner read = new Scanner(System.in); int i,j,k,n,h,t,step; long sum; n=read.nextInt(); k=read.nextInt(); h=1; t=n; sum=0; for (i=h;i<=t;i++){ arr[i] = read.nex...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
2f6713ee896223010cffa1ad5a30d441
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.*; public class Main{ public static void main(String... args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); if (n==1){System.out.println(0);System.exit(0);} boolean same = true; int prev=sc.nextInt(); int sameFrom=1; for (int i=2; i<=n; i++){ int curr = sc.nextIn...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
3984ffd8821ac9bbf7829c7e7b91adc2
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.*; public class JavaApplication198 { public static void main(String[] args) { Scanner sin = new Scanner(System.in); int n = sin.nextInt(), k = sin.nextInt(), arr[] = new int[n]; for(int i = 0; i < n; i++) arr[i] = sin.nextInt(); int ans = -1; f...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
9e57b80b33f62aee3b24ed0b1abaadbf
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.io.IOException; import java.io.InputStream; public class A222 { public static void main(String[] args) throws IOException { InputReader reader = new InputReader(System.in); int N = reader.readInt(); int K = reader.readInt()-1; int[] A = new int[N]; for (int n=0;...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
83b9c3f0eaade082d5462e5c89479004
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; public class ShooshunsandSequence { static int arr[]; static int check(int indx, int len) { boolean check = true; int index = 0; for (int i = indx; i < len; i++) { if (arr[indx] != arr[i]) { index = -1; break; ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
fb12ba04f66ac0f2903d0562f9dde416
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.io.*; import java.util.*; public class cf{ public static void main(String argc[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(), k = sc.nextInt(), a[]; a = new int[n]; for (int i = 0; i < n; i++) a[i] = sc.nextInt(); boolean tt = true; for (int i = k - 1; i < n - 1; i++) if...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
8632b2089e9f4e7911c32e35002309b6
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.*; public class ShooshunsAndSequence { public static void main(String[] Args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int[] vals = new int[n]; for(int j =0;j<n;j++) vals[j] = sc.nextInt(); boolean ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
b9b3c5950b8a615c207cbac82417818b
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String y[] = in.readLine().split(" "); int n = Integer.parseInt(...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
3b16714e023edeb92ee603751850e280
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); int k = sc.nextInt(); int[] a = new int[n]; for...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
f2ddb3566593054abff3e1024b6a0832
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.lang.Integer.*; import static java.lang.System.*; public class Main { static InputReader in; public static void main(String[] args) throws IOException{ ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
44c9b140cef88950756c07549d28bd36
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author dudkamaster */ public class...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
bb6ad23782e90d2b6761d357ff515c1d
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; public class ShooshunsAndSequence { public static void main(String[] args) { int m,n; Scanner sc=new Scanner(System.in); m=sc.nextInt(); n=sc.nextInt(); int count=0,counter=0; int [] no= new int [m]; for (int i=0;i<m;i++) ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
b510feceb3717afda8deb26c25120fc2
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.*; import java.io.*; public class Main{ static public void main(String args[]) { Scanner in = new Scanner(new BufferedInputStream(System.in)); int n = in.nextInt(), m = in.nextInt(), a[]; a = new int[n + 1]; a[0] = 0; for (int i = 1; i <= n; i++) a[i] = in.nextInt(); for (int i = m; i <= ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
7d67d0a87ef5bba5db66f25eea83186a
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; /** * * @author Colonelm0 */ public class Main { public static void main(String[] args) { Scanner inp = new Scanner(System.in) ; int n , k ; n = inp.nextInt() ; k = inp.nextInt() ; boolean poss =true ; int [] arr = new int[100002]; ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
baa029a235b7640e34eace1193452cee
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; /** * @author Son-Huy TRAN * */ public class P222A_ShooshunsAndSequence { private static int stepCount(int n, int k, int[] numbers) { for (int i = k + 1; i <= n; i++) { if (numbers[i] != numbers[k]) { return -1; } } int i = k - 1; while (i >= 0 && numbers[i] == numbe...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
39a546c75597afb5f0369c0225a42348
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Solution { public static void main(String[] args) throws IOException { new Solution().run(); } StreamTokenizer in; Scanner ins; PrintWriter out; int nextInt() throws IOException { in.nextToken(); ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
f698cd2de33ce219b08dc4f3d7958148
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.Scanner; import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author George Marcus */ public class Main { public static void main(String[] args) { InputStream inputSt...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
00d4151bf2ffee23c3218d47289ff0e5
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Locale; import java.util.StringTokenizer; public class Problem implements Runnable { public static void main(String[] args) { new Problem().run(); } final bo...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
ad1bfb0a242476cc7023729df114454c
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Locale; import java.util.StringTokenizer; public class Problem implements Runnable { public static void main(String[] args) { new Problem().ru...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
57356efeb6486669958ea2357e0fe16d
train_002.jsonl
1347291900
One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: Find the number that goes k-th in the current sequence and add the same number to the end of the sequence; Delete the first number of the current sequence. T...
256 megabytes
import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class practice { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int [] arr = new int[n]; for(int i = 0; i<n; i++) arr[i] = ...
Java
["3 2\n3 1 1", "3 1\n3 1 1"]
2 seconds
["1", "-1"]
NoteIn the first test case after the first operation the blackboard will have sequence [1, 1, 1]. So, one operation is enough to make all numbers the same. Thus, the answer equals one.In the second test case the sequence will never consist of the same numbers. It will always contain at least two distinct numbers 3 and ...
Java 7
standard input
[ "implementation", "brute force" ]
bcee233ddb1509a14f2bd9fd5ec58798
The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 105). The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 105) — the sequence that the shooshuns found.
1,200
Print the minimum number of operations, required for all numbers on the blackboard to become the same. If it is impossible to achieve, print -1.
standard output
PASSED
c3db4d9a25db94da954e01dae882a881
train_002.jsonl
1380295800
You are given a rooted tree with n vertices. In each leaf vertex there's a single integer — the number of apples in this vertex. The weight of a subtree is the sum of all numbers in this subtree leaves. For instance, the weight of a subtree that corresponds to some leaf is the number written in the leaf.A tree is balan...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); ...
Java
["6\n0 0 12 13 5 6\n1 2\n1 3\n1 4\n2 5\n2 6"]
2 seconds
["6"]
null
Java 8
standard input
[ "number theory", "dfs and similar", "trees" ]
db1c28e9ac6251353fbad8730f4705ea
The first line contains integer n (2 ≤ n ≤ 105), showing the number of vertices in the tree. The next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 108), ai is the number of apples in the vertex number i. The number of apples in non-leaf vertices is guaranteed to be zero. Then follow n - 1 lines, describing the t...
2,100
Print a single integer — the minimum number of apples to remove in order to make the tree balanced. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the sin, cout streams cin, cout or the %I64d specifier.
standard output
PASSED
e7e3d7bd5c11902215ddb698144ce6f2
train_002.jsonl
1380295800
You are given a rooted tree with n vertices. In each leaf vertex there's a single integer — the number of apples in this vertex. The weight of a subtree is the sum of all numbers in this subtree leaves. For instance, the weight of a subtree that corresponds to some leaf is the number written in the leaf.A tree is balan...
256 megabytes
import java.io.*; import java.util.*; public class CF349D { static final double MAX = 1e13; // 1e5 * 1e8 static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); } static class Vertex { int a; List<Vertex> list = new ArrayList<Vertex>(); long sum, unit; Vertex(int a) { this.a = a; } vo...
Java
["6\n0 0 12 13 5 6\n1 2\n1 3\n1 4\n2 5\n2 6"]
2 seconds
["6"]
null
Java 8
standard input
[ "number theory", "dfs and similar", "trees" ]
db1c28e9ac6251353fbad8730f4705ea
The first line contains integer n (2 ≤ n ≤ 105), showing the number of vertices in the tree. The next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 108), ai is the number of apples in the vertex number i. The number of apples in non-leaf vertices is guaranteed to be zero. Then follow n - 1 lines, describing the t...
2,100
Print a single integer — the minimum number of apples to remove in order to make the tree balanced. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the sin, cout streams cin, cout or the %I64d specifier.
standard output
PASSED
ba789315d65644e02b5af315c7b058a1
train_002.jsonl
1380295800
You are given a rooted tree with n vertices. In each leaf vertex there's a single integer — the number of apples in this vertex. The weight of a subtree is the sum of all numbers in this subtree leaves. For instance, the weight of a subtree that corresponds to some leaf is the number written in the leaf.A tree is balan...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Stack; public class D349 { public static void main(String[] args)throws Exception{ // TODO Auto-generated method stub ...
Java
["6\n0 0 12 13 5 6\n1 2\n1 3\n1 4\n2 5\n2 6"]
2 seconds
["6"]
null
Java 6
standard input
[ "number theory", "dfs and similar", "trees" ]
db1c28e9ac6251353fbad8730f4705ea
The first line contains integer n (2 ≤ n ≤ 105), showing the number of vertices in the tree. The next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 108), ai is the number of apples in the vertex number i. The number of apples in non-leaf vertices is guaranteed to be zero. Then follow n - 1 lines, describing the t...
2,100
Print a single integer — the minimum number of apples to remove in order to make the tree balanced. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the sin, cout streams cin, cout or the %I64d specifier.
standard output
PASSED
c506f3b2496345c2a27ddaa3eed7e62f
train_002.jsonl
1380295800
You are given a rooted tree with n vertices. In each leaf vertex there's a single integer — the number of apples in this vertex. The weight of a subtree is the sum of all numbers in this subtree leaves. For instance, the weight of a subtree that corresponds to some leaf is the number written in the leaf.A tree is balan...
256 megabytes
import java.util.*; import java.io.*; public class b { static ArrayList<Integer>[] tree; static long[] data; static long mod = 1000000007; public static void main(String[] args) throws IOException { // Scanner input = new Scanner(new File("input.txt")); // PrintWriter out = new PrintWri...
Java
["6\n0 0 12 13 5 6\n1 2\n1 3\n1 4\n2 5\n2 6"]
2 seconds
["6"]
null
Java 6
standard input
[ "number theory", "dfs and similar", "trees" ]
db1c28e9ac6251353fbad8730f4705ea
The first line contains integer n (2 ≤ n ≤ 105), showing the number of vertices in the tree. The next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 108), ai is the number of apples in the vertex number i. The number of apples in non-leaf vertices is guaranteed to be zero. Then follow n - 1 lines, describing the t...
2,100
Print a single integer — the minimum number of apples to remove in order to make the tree balanced. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the sin, cout streams cin, cout or the %I64d specifier.
standard output
PASSED
418fa3f727d119b12be0012ae5707165
train_002.jsonl
1380295800
You are given a rooted tree with n vertices. In each leaf vertex there's a single integer — the number of apples in this vertex. The weight of a subtree is the sum of all numbers in this subtree leaves. For instance, the weight of a subtree that corresponds to some leaf is the number written in the leaf.A tree is balan...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class D { private int n; private int[] w; private long wsum; private List<Integer>[] e; private long[] h; private int[] cnum; public static void main(String[] args) { D sol...
Java
["6\n0 0 12 13 5 6\n1 2\n1 3\n1 4\n2 5\n2 6"]
2 seconds
["6"]
null
Java 6
standard input
[ "number theory", "dfs and similar", "trees" ]
db1c28e9ac6251353fbad8730f4705ea
The first line contains integer n (2 ≤ n ≤ 105), showing the number of vertices in the tree. The next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 108), ai is the number of apples in the vertex number i. The number of apples in non-leaf vertices is guaranteed to be zero. Then follow n - 1 lines, describing the t...
2,100
Print a single integer — the minimum number of apples to remove in order to make the tree balanced. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the sin, cout streams cin, cout or the %I64d specifier.
standard output
PASSED
89813791c88007c5e7f03b310e7c5a03
train_002.jsonl
1585924500
Dreamoon likes strings. Today he created a game about strings:String $$$s_1, s_2, \ldots, s_n$$$ is beautiful if and only if for each $$$1 \le i &lt; n, s_i \ne s_{i+1}$$$.Initially, Dreamoon has a string $$$a$$$. In each step Dreamoon can choose a beautiful substring of $$$a$$$ and remove it. Then he should concatenat...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.io.IOException; import java.util.TreeSet; import java.util.ArrayList; import java.io.UncheckedIOException; import java.util.List; import java.io.Closeable; import jav...
Java
["4\naabbcc\naaabbb\naaa\nabacad"]
2 seconds
["3\n3 3\n2 4\n1 2\n3\n3 4\n2 3\n1 2\n3\n1 1\n1 1\n1 1\n1\n1 6"]
null
Java 8
standard input
[ "data structures", "constructive algorithms" ]
1cb409e072d38270a5d84afd86b599a6
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 200\,000$$$), denoting the number of test cases in the input. For each test case, there's one line with a non-empty string of lowercase Latin letters $$$a$$$. The total sum of lengths of strings in all test cases is at most $$$200\,000$$$.
3,100
For each test case, in the first line, you should print $$$m$$$: the smallest number of steps to make $$$a$$$ empty. Each of the following $$$m$$$ lines should contain two integers $$$l_i, r_i$$$ ($$$1 \leq l_i \leq r_i \leq |a|$$$), denoting, that the $$$i$$$-th step is removing the characters from index $$$l_i$$$ to ...
standard output
PASSED
bb530b1ac03bb3e2e85951b1ce15c488
train_002.jsonl
1518861900
Dima has a hamsters farm. Soon N hamsters will grow up on it and Dima will sell them in a city nearby.Hamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's why each box should be completely full with hamsters.Dima can buy boxes at a factory. The factory produc...
256 megabytes
import java.util.*; import java.lang.Math; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); int k = sc.nextInt(); long minmod=n; long d=0; long d1=0; long a[]=new long[k]; int in=0; lon...
Java
["19 3\n5 4 10", "28 3\n5 6 30"]
2 seconds
["2 4", "1 5"]
null
Java 11
standard input
[ "implementation" ]
8e36566b5e0c74730ea118e23b030778
The first line contains two integers N and K (0 ≤ N ≤ 1018, 1 ≤ K ≤ 105) — the number of hamsters that will grow up on Dima's farm and the number of types of boxes that the factory produces. The second line contains K integers a1, a2, ..., aK (1 ≤ ai ≤ 1018 for all i) — the capacities of boxes.
1,000
Output two integers: the type of boxes that Dima should buy and the number of boxes of that type Dima should buy. Types of boxes are numbered from 1 to K in the order they are given in input. If there are many correct answers, output any of them.
standard output
PASSED
563899c79cbe6f6a8bfba7e9f72fd08e
train_002.jsonl
1518861900
Dima has a hamsters farm. Soon N hamsters will grow up on it and Dima will sell them in a city nearby.Hamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's why each box should be completely full with hamsters.Dima can buy boxes at a factory. The factory produc...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner scanner = new Scanner(System.in)...
Java
["19 3\n5 4 10", "28 3\n5 6 30"]
2 seconds
["2 4", "1 5"]
null
Java 11
standard input
[ "implementation" ]
8e36566b5e0c74730ea118e23b030778
The first line contains two integers N and K (0 ≤ N ≤ 1018, 1 ≤ K ≤ 105) — the number of hamsters that will grow up on Dima's farm and the number of types of boxes that the factory produces. The second line contains K integers a1, a2, ..., aK (1 ≤ ai ≤ 1018 for all i) — the capacities of boxes.
1,000
Output two integers: the type of boxes that Dima should buy and the number of boxes of that type Dima should buy. Types of boxes are numbered from 1 to K in the order they are given in input. If there are many correct answers, output any of them.
standard output
PASSED
64cf57f7425268918a526e4e91f81728
train_002.jsonl
1518861900
Dima has a hamsters farm. Soon N hamsters will grow up on it and Dima will sell them in a city nearby.Hamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's why each box should be completely full with hamsters.Dima can buy boxes at a factory. The factory produc...
256 megabytes
import java.util.*; public class CF939B { public static void main(String[] args) { Scanner s=new Scanner(System.in); long N=s.nextLong(); int k=s.nextInt(); long[] arr=new long[k]; for(int i=0;i<arr.length;i++){ arr[i]=s.nextLong(); } int idx=0; ...
Java
["19 3\n5 4 10", "28 3\n5 6 30"]
2 seconds
["2 4", "1 5"]
null
Java 11
standard input
[ "implementation" ]
8e36566b5e0c74730ea118e23b030778
The first line contains two integers N and K (0 ≤ N ≤ 1018, 1 ≤ K ≤ 105) — the number of hamsters that will grow up on Dima's farm and the number of types of boxes that the factory produces. The second line contains K integers a1, a2, ..., aK (1 ≤ ai ≤ 1018 for all i) — the capacities of boxes.
1,000
Output two integers: the type of boxes that Dima should buy and the number of boxes of that type Dima should buy. Types of boxes are numbered from 1 to K in the order they are given in input. If there are many correct answers, output any of them.
standard output
PASSED
c57b7cb35e138406f450b4dad9e5cd6d
train_002.jsonl
1518861900
Dima has a hamsters farm. Soon N hamsters will grow up on it and Dima will sell them in a city nearby.Hamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's why each box should be completely full with hamsters.Dima can buy boxes at a factory. The factory produc...
256 megabytes
import java.io.*; import java.util.*; public class hamster { public static void main(String[] args) throws IOException { //BufferedReader br = new BufferedReader(new FileReader("sn")); //PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("shuffle.out"))); BufferedReader br=new BufferedReader(new ...
Java
["19 3\n5 4 10", "28 3\n5 6 30"]
2 seconds
["2 4", "1 5"]
null
Java 11
standard input
[ "implementation" ]
8e36566b5e0c74730ea118e23b030778
The first line contains two integers N and K (0 ≤ N ≤ 1018, 1 ≤ K ≤ 105) — the number of hamsters that will grow up on Dima's farm and the number of types of boxes that the factory produces. The second line contains K integers a1, a2, ..., aK (1 ≤ ai ≤ 1018 for all i) — the capacities of boxes.
1,000
Output two integers: the type of boxes that Dima should buy and the number of boxes of that type Dima should buy. Types of boxes are numbered from 1 to K in the order they are given in input. If there are many correct answers, output any of them.
standard output
PASSED
28eeee552140086161b866de78efa1f4
train_002.jsonl
1518861900
Dima has a hamsters farm. Soon N hamsters will grow up on it and Dima will sell them in a city nearby.Hamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's why each box should be completely full with hamsters.Dima can buy boxes at a factory. The factory produc...
256 megabytes
import java.util.*; public class cf464div2B { public static void main(String[] args) { Scanner sc=new Scanner(System.in); long n=sc.nextLong(); long k=sc.nextLong(); long min=(long)Math.pow(10,19);long x=0;long y=0; for(long i=0;i<k;i++) {long a=sc.nextLong(); ...
Java
["19 3\n5 4 10", "28 3\n5 6 30"]
2 seconds
["2 4", "1 5"]
null
Java 11
standard input
[ "implementation" ]
8e36566b5e0c74730ea118e23b030778
The first line contains two integers N and K (0 ≤ N ≤ 1018, 1 ≤ K ≤ 105) — the number of hamsters that will grow up on Dima's farm and the number of types of boxes that the factory produces. The second line contains K integers a1, a2, ..., aK (1 ≤ ai ≤ 1018 for all i) — the capacities of boxes.
1,000
Output two integers: the type of boxes that Dima should buy and the number of boxes of that type Dima should buy. Types of boxes are numbered from 1 to K in the order they are given in input. If there are many correct answers, output any of them.
standard output
PASSED
173d87bb259765488b8ad279bfaec0e4
train_002.jsonl
1518861900
Dima has a hamsters farm. Soon N hamsters will grow up on it and Dima will sell them in a city nearby.Hamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's why each box should be completely full with hamsters.Dima can buy boxes at a factory. The factory produc...
256 megabytes
// practice with kaiboy import java.io.*; import java.util.*; public class CF939B extends PrintWriter { CF939B() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF939B o = new CF939B(); o.main(); o.flush(); } void main() { long n = sc.nextLong(); int ...
Java
["19 3\n5 4 10", "28 3\n5 6 30"]
2 seconds
["2 4", "1 5"]
null
Java 11
standard input
[ "implementation" ]
8e36566b5e0c74730ea118e23b030778
The first line contains two integers N and K (0 ≤ N ≤ 1018, 1 ≤ K ≤ 105) — the number of hamsters that will grow up on Dima's farm and the number of types of boxes that the factory produces. The second line contains K integers a1, a2, ..., aK (1 ≤ ai ≤ 1018 for all i) — the capacities of boxes.
1,000
Output two integers: the type of boxes that Dima should buy and the number of boxes of that type Dima should buy. Types of boxes are numbered from 1 to K in the order they are given in input. If there are many correct answers, output any of them.
standard output