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
efb63628a024d798eba0ccc5e92b5703
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.util.*; // scanner.nextInt(); public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int test_case = scanner.nextInt(); for(int z = 0; z < test_case; ++z) { int n = scanner.ne...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
7fe8963840640507caa8c3ce41d98d8c
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.io.*; import java.util.*; /** * Created by Katushka on 11.03.2020. */ public class B { static int[] readArray(int size, InputReader in) { int[] a = new int[size]; for (int i = 0; i < size; i++) { a[i] = in.nextInt(); } return a; } static long[] rea...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
f5541253c4364e881bc69af162aa0608
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.util.*; import java.io.*; public class lp{ static PrintWriter out = new PrintWriter(System.out); static int mod =1000000007; static int max = 1000000000; static int fun(int a[],int n,int x){ int min = 0; for(int i=0;i<n;i++){ if(a[i]==-1){ if((i-1)>=0&&a[i-1]!=-1&&abs(a[i-1]-x)>min) ...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
2ccd814922ad723ffe8848d2dd1bae30
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner input = new Scanner(System.in); int t = input.nextInt(); whi...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
decd3d664c789d1a52c094c61dff1881
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.util.Scanner; public class MotBirth { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t--!=0) { int n = sc.nextInt(); long[] arr = new long[n]; for(int i = 0; i < n; i++) arr[i] = sc.nextLong(); long min = (l...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
c7d30373cf3ae88874a7481a82f83b99
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputStream...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
9250b0b72572045cb55126aa22c78e4e
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; import java.io.*; public class Main { public static void main(String args[]) { InputReader obj = new InputReader(System.in); int t=obj.n...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
2e044cf954a1c07d4da361619d1e7540
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { InputStream inputS...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
08e043c510b030b26c8e1da5cb8d0416
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.util.Scanner; //http://codeforces.com/problemset/problem/1301/B public class HBMotaraka { private static void fillMissedValues(Scanner sc) { int n = sc.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; ++i) { arr[i] = sc.nextInt(); } int minA ...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
a5067bc2fa57beb5bbb356ca108c6119
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class ProblemB { public static InputStream inputStream = System.in; public static OutputStream outputStream = System.out; public static...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
9efd3486e44ef5628b764a38420728b0
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int tst = Integer.parseInt(br.readLine()); while(tst-...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
a01774acc0871379f9e2d033874cf932
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.io.*; import java.util.*; public class utkarsh { BufferedReader br; PrintWriter out; long mod = (long) (1e9 + 7), inf = (long) (3e18); void solve() { int t = ni(); A: while(t-- > 0) { int n = ni(); long a[] = new long[n]; f...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
766c02c6cae7dc2d92bcb9407244e72d
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
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.util.Collections; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputSt...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
e3d81522b1f4fb280bde4a9faab422b1
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.util.*; import java.util.ArrayList; public class Main{ static class Pair { int x; int y; Pair(int x, int y){ this.x=x; this.y=y; } } public static void main(String[] args){ Scanner param = new Scanner(System.in);...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
8d912b6df6daaa875946a3784ddd49f4
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.util.*; import java.math.*; import java.io.*; import java.lang.*; public class Main { public static void main(String[] args) { FastReader sc =new FastReader(); int t = sc.nextInt(); while(t-- > 0) { int n=sc.nextInt(); int a[]=sc.nextIntArray(n); ...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
6f79ed9e42d4fa93a98a1b722f98ce80
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Iterator; import java.util.StringTokenizer; public class MotaracksBirthday { public static void main(String[] args) { FastReader input=new FastReader(); int t=inpu...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
83f2bdad654acb02c9e7e46dbf8b7e52
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.util.*; public class codeforce { public static void main(String args[]) { Scanner sj = new Scanner(System.in); int t = sj.nextInt(); while(t-->0){ int n = sj.nextInt(); long a[] = new long[n]; long min = Integer.MAX_VALUE, max = Integer.MIN_VALUE; for(int i=0;i<n;i++){ a[i] = sj.nex...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
5c55d9e79a870537ab2f137f42d63463
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.Collections; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
29ff9c0b526b039d84f4ca422c29602a
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
// package Codef; import java.util.Scanner; public class B_1301 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int t = s.nextInt(); while (t-- > 0) { int n = s.nextInt(); long[] a = new long[n]; for (int i = 0; i < n; i++) { a[i...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
d98883dcd96c5bc720cf8fbf8fddab1d
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.util.Scanner; public class MainClass { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); for (; t > 0; t--) { int n = scan.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = scan.nextInt(); } ...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
f7cca4a6d616c5351b174e152052625c
train_002.jsonl
1468514100
Barney was hanging out with Nora for a while and now he thinks he may have feelings for her. Barney wants to send her a cheesy text message and wants to make her as happy as possible. Initially, happiness level of Nora is 0. Nora loves some pickup lines like "I'm falling for you" and stuff. Totally, she knows n pickup...
256 megabytes
import java.io.IOException; import java.io.PrintStream; import java.util.Scanner; import java.util.SortedSet; import java.util.TreeSet; public class F { private static Scanner in = new Scanner(System.in); private static PrintStream out = System.out; public static class MatrixDP { private long best(long a, long...
Java
["3 6\n3 2 1\nheart\nearth\nart", "3 6\n3 2 8\nheart\nearth\nart"]
6 seconds
["6", "16"]
NoteAn optimal answer for the first sample case is hearth containing each pickup line exactly once.An optimal answer for the second sample case is artart.
Java 8
standard input
[ "dp", "data structures", "strings" ]
24a59fe61d996a5fd0a8fa64995f13e4
The first line of input contains two integers n and l (1 ≤ n ≤ 200, 1 ≤ l ≤ 1014) — the number of pickup lines and the maximum length of Barney's text. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 100), meaning that Nora's happiness level increases by ai after every time seeing i-th pickup line. The ne...
2,500
Print the only integer — the maximum possible value of Nora's happiness level after reading Barney's text.
standard output
PASSED
56683a715f211004fd127da96c146e12
train_002.jsonl
1468514100
Barney was hanging out with Nora for a while and now he thinks he may have feelings for her. Barney wants to send her a cheesy text message and wants to make her as happy as possible. Initially, happiness level of Nora is 0. Nora loves some pickup lines like "I'm falling for you" and stuff. Totally, she knows n pickup...
256 megabytes
import java.io.PrintStream; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Scanner; import java.util.Set; // Q: how do we even know we can do this matrix thing? public class F { private static Scanner in = new Scanner(System.in); private static PrintStream out = System.o...
Java
["3 6\n3 2 1\nheart\nearth\nart", "3 6\n3 2 8\nheart\nearth\nart"]
6 seconds
["6", "16"]
NoteAn optimal answer for the first sample case is hearth containing each pickup line exactly once.An optimal answer for the second sample case is artart.
Java 8
standard input
[ "dp", "data structures", "strings" ]
24a59fe61d996a5fd0a8fa64995f13e4
The first line of input contains two integers n and l (1 ≤ n ≤ 200, 1 ≤ l ≤ 1014) — the number of pickup lines and the maximum length of Barney's text. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 100), meaning that Nora's happiness level increases by ai after every time seeing i-th pickup line. The ne...
2,500
Print the only integer — the maximum possible value of Nora's happiness level after reading Barney's text.
standard output
PASSED
4f0733f40fe8cc9e7a3a0aa0d3d9d6ec
train_002.jsonl
1385479800
Sereja has two sequences a and b and number p. Sequence a consists of n integers a1, a2, ..., an. Similarly, sequence b consists of m integers b1, b2, ..., bm. As usual, Sereja studies the sequences he has. Today he wants to find the number of positions q (q + (m - 1)·p ≤ n; q ≥ 1), such that sequence b can be obtained...
256 megabytes
import java.util.*; import java.io.*; public class AlgorithmInfinite { public static void main(String[] args) throws IOException { BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); StringTokenizer st = new StringTokenizer(rd.readLine()); in...
Java
["5 3 1\n1 2 3 2 1\n1 2 3", "6 3 2\n1 3 2 2 3 1\n1 2 3"]
1 second
["2\n1 3", "2\n1 2"]
null
Java 6
standard input
[ "data structures", "binary search" ]
84cce147e8aadb140afaaa95917fdf0d
The first line contains three integers n, m and p (1 ≤ n, m ≤ 2·105, 1 ≤ p ≤ 2·105). The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109). The next line contains m integers b1, b2, ..., bm (1 ≤ bi ≤ 109).
1,900
In the first line print the number of valid qs. In the second line, print the valid values in the increasing order.
standard output
PASSED
bf671727c92c787b0aa114100901ac60
train_002.jsonl
1385479800
Sereja has two sequences a and b and number p. Sequence a consists of n integers a1, a2, ..., an. Similarly, sequence b consists of m integers b1, b2, ..., bm. As usual, Sereja studies the sequences he has. Today he wants to find the number of positions q (q + (m - 1)·p ≤ n; q ≥ 1), such that sequence b can be obtained...
256 megabytes
import java.util.List; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.ArrayList; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.HashSet; import java.util.Collections; impo...
Java
["5 3 1\n1 2 3 2 1\n1 2 3", "6 3 2\n1 3 2 2 3 1\n1 2 3"]
1 second
["2\n1 3", "2\n1 2"]
null
Java 6
standard input
[ "data structures", "binary search" ]
84cce147e8aadb140afaaa95917fdf0d
The first line contains three integers n, m and p (1 ≤ n, m ≤ 2·105, 1 ≤ p ≤ 2·105). The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109). The next line contains m integers b1, b2, ..., bm (1 ≤ bi ≤ 109).
1,900
In the first line print the number of valid qs. In the second line, print the valid values in the increasing order.
standard output
PASSED
8e8788ee635218139f9a96240587b59f
train_002.jsonl
1385479800
Sereja has two sequences a and b and number p. Sequence a consists of n integers a1, a2, ..., an. Similarly, sequence b consists of m integers b1, b2, ..., bm. As usual, Sereja studies the sequences he has. Today he wants to find the number of positions q (q + (m - 1)·p ≤ n; q ≥ 1), such that sequence b can be obtained...
256 megabytes
//package round215; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Random; public class B { InputStream is; PrintWriter out; String INPUT = ""; void solve()...
Java
["5 3 1\n1 2 3 2 1\n1 2 3", "6 3 2\n1 3 2 2 3 1\n1 2 3"]
1 second
["2\n1 3", "2\n1 2"]
null
Java 6
standard input
[ "data structures", "binary search" ]
84cce147e8aadb140afaaa95917fdf0d
The first line contains three integers n, m and p (1 ≤ n, m ≤ 2·105, 1 ≤ p ≤ 2·105). The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109). The next line contains m integers b1, b2, ..., bm (1 ≤ bi ≤ 109).
1,900
In the first line print the number of valid qs. In the second line, print the valid values in the increasing order.
standard output
PASSED
5981e200cc2b33eadbbe5ec511518729
train_002.jsonl
1385479800
Sereja has two sequences a and b and number p. Sequence a consists of n integers a1, a2, ..., an. Similarly, sequence b consists of m integers b1, b2, ..., bm. As usual, Sereja studies the sequences he has. Today he wants to find the number of positions q (q + (m - 1)·p ≤ n; q ≥ 1), such that sequence b can be obtained...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws IOException { B solver = new B(); solver.solve(); } private void solve() throws IOException { FastScanner sc = new FastScanner(System.in); // sc = new FastScanner("5 3 1\n" ...
Java
["5 3 1\n1 2 3 2 1\n1 2 3", "6 3 2\n1 3 2 2 3 1\n1 2 3"]
1 second
["2\n1 3", "2\n1 2"]
null
Java 6
standard input
[ "data structures", "binary search" ]
84cce147e8aadb140afaaa95917fdf0d
The first line contains three integers n, m and p (1 ≤ n, m ≤ 2·105, 1 ≤ p ≤ 2·105). The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109). The next line contains m integers b1, b2, ..., bm (1 ≤ bi ≤ 109).
1,900
In the first line print the number of valid qs. In the second line, print the valid values in the increasing order.
standard output
PASSED
259f1ce82d98c6119b58fc9ce489ea4b
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.util.*; import java.io.*; public class Main { static class Scan { private byte[] buf=new byte[1024]; private int index; private InputStream in; private int total; public Scan() { in=System.in; } public int scan()throws IOExcepti...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
4fb7a3dfe5a672dfc794426724345361
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
/** * ******* Created on 25/2/20 12:44 PM******* */ import java.io.*; import java.util.*; public class ED82D implements Runnable { private static final int MAX = (int) (1E5 + 5); private static final int MOD = (int) (1E9 + 7); private static final long Inf = (long) (1E14 + 10); private void solve...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
c1a82b876f712543a4b38c1f40691f14
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.util.*; import java.io.*; public class d { public static PrintWriter out; public static FS sc; public static void main(String[] Args) throws Exception { sc = new FS(System.in); out = new PrintWriter( new BufferedWriter( new OutputStreamW...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
e901a6201cd61084aebf776fa00d5ff2
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.util.Scanner; public class Main{ public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a[] = new int[105],p[] = new int[105]; long n,m,t; t = sc.nextLong(); while(t-- > 0) { for(int i = 0; i < 105; i++) a[i] = 0; for(int i = 0; i < 105; i+...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
6399fa45891affe6b9c02243ec783900
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.*; public class sol { static long mod=(long)Math.pow(10,9)+7; static StringBuilder sb = new StringBuilder(); static ArrayList<Integer> tree[]; static boolean vis[]; static int a[],freq[]; public static void main(String args...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
e357f1a828fbcd86cdd57f30342cabc0
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class d { public static void print(String str,int val){ System.out.println(str+" "+val); } public long gcd(long a, long b) { if (b==0L) return a; return gcd(b,a%b); }...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
ce3334fd4027716ca31a78433541dfa1
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Solve8 { public static void main(String[] args) throws I...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
e44534dca38d548029b25dcc1218787b
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tests = sc.nextInt(); while (tests-- > 0) { long n = sc.nextLong(); int m = sc.nextInt(); int[] b = new int[64]; fo...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
a8ac842c303c35d57d45cc59a87d20c4
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.*; import java.util.*; public class CF1303D extends PrintWriter { CF1303D() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1303D o = new CF1303D(); o.main(); o.flush(); } static final int B = 60; void main() { int[] kk = new int[B]; int t...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
21ec25764ed8f90be32efc503f80f38d
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.*; import java.util.*; public class Main{ public static void main(String[] args) throws Exception{ MScanner sc=new MScanner(System.in); PrintWriter pw=new PrintWriter(System.out); int tc=sc.nextInt(); o:while(tc-->0) { long n=sc.nextLong();int m=sc.nextInt(); long[]powersOf2=new long[64...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
aa9714ed01c9af8996c860f76168cf98
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.*; import java.util.*; public class C { static int MAX = 63; static int get(int needed, int[] cnt) { for (int i = needed; i < cnt.length; i++) if (cnt[i] > 0) return i; return -1; } public static void main(String[] args) throws IOException { Scanner sc = new Scanner(); PrintWriter ...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
bfd6f38b41ca999d8bcebdb90b784766
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.TreeSet; public class r82p4{ private static InputReader sc; private static PrintWriter pw; static class InputRea...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
a97b3c874d8f817bcc1e43edcb00906b
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf1303d { public static void main(String[] args) throws IOException { int t = ri(); next: while(t --> 0) { long n = rnl(), bit = 1; int m = ni(), cnt[] = ne...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
46c2440ec18d10fbfe1db0d0285162a0
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
// package com.codeforces; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class FillTheBag { private static Map<Long, Integer> power = new HashMap<>(); private static long[] result = new long[70]; private long[] has = new long[70]; private long[] size = new long[70];...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
63d901ed99f131b8c5b14eccecea7c61
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author LUCIANO. */ import java.util.*; public class Solve { /** * @param args the command line arguments *...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
13ee79964d89d7b07cf6b62309259ac4
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; /* Hepler Class Methods **only Few Imp Ones** * int[][] getIntMatrix(String s,int r,int c) //Works only for int and long * char getCharacterValue(int i) * int getIntegerValueOfCharacter(char c) * boolean isPerfectSquare(int n) ...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
880e3e28606bee84723f68f667585a84
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.util.Scanner; import java.util.HashMap; import java.util.Arrays; public class FillTheBag { public static void main(String[] args) { Scanner s = new Scanner(System.in); int c = s.nextInt(); for (int i = 0; i < c; i++) { long n = s.nextLong(); int m = s.nex...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
86b17ad5257daf4443d2255bdf3b10ad
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.BufferedOutputStream; import java.io.Closeable; import java.io.DataInputStream; import java.io.Flushable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.InputMismatchException; /** * Built using CHelper plug-in * Actual solution is at the top */ ...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
8352382cbd5621c810433a4478c5adf7
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.*; import java.util.*; public class D { void solve(FastIO io) { long n = io.nextLong(); int m = io.nextInt(); long all = 0; Long[] sort = new Long[m]; for (int i = 0; i < m; i++) all += sort[i] = io.nextLong(); if (all < n) { ...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
2dcfa3b28bed9645d0fc5a52afb282ff
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Jenish */ public class Ma...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
e3b78a605d82f3e9c56c922035c55dc3
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
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.*; public class Main { static int get(int needed, int[] cnt) { for (int i = needed; i < cnt.length; i++) if (cnt[i] > 0) ...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
82fd944ecafd709aa33124d84b465492
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.*; import java.util.*; //import javafx.util.*; import java.math.*; //import java.lang.*; public class Main { // static int n; static HashSet<Integer> adj[]; static boolean vis[]; // static long ans[]; static int arr[]; static long mod=1000000007; static final lo...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
4b4913e1d1bc156f742c202391da2b20
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
//package educational.round82; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class D { InputStream is; PrintWriter out; String INPUT = ""; void solve() { for(int ...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
16ad632c87c6ff1addb915ee62e88ce8
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { FastScanner in = new FastScanner(); int q = in.nextInt(); while (q-- > 0) { long n = in.nextLong(); int m = in.nextInt(); int k = 60; ...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
7e54fd4828b7c69ad1a439e3248d2985
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) { Problem problem = new Problem(); problem.solve(); } } class Problem { private final Parser parser = new Parser(); void solve() { ...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
f5424b46091f7c585c768bfa0dc64214
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.util.*; import java.io.*; public class D { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine()); while(t--...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
18c28ae9a85cf6d9d659c4a328789418
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.util.*; import java.io.*; public class Main { static FastReader in=new FastReader(); public static void main(String [] args) { int t=in.nextInt(); while(t-->0){ long nn=in.nextLong(),n=nn,sum=0L; int m=in.nextInt(); int x[]=new int [61],c[]=new int[61],ll=0; while(n>0)...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
ef17aec0091d2c1830864e15a82b28bf
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
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.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.PriorityQueue; import ...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
c8bef944bd5dd1b2efe193282f527725
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; 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.StringTokenizer;...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
6330dde093a9ef6e6a53ad37a9557bc7
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import javafx.util.Pair; import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main implements Runnable { boolean multiple = true; long MOD = 1000000007; @SuppressWarnings("Duplicates") void solve() throws Exception { long n = sc.nextLong(); long m = s...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
0827b72c1f8fff9eca785505addb7794
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.util.regex.*; public class Solution { static class Pair<E, V> implements Comparable<Pair<E, V>>{ E a; V b; public Pair(E x, V y) {a = x;b=y;} public int compareTo(Pair<E, V> p){ return Integer.compare((Integer)...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
a9eb68a0aab91044b1ffb46545e3befe
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); //br = new BufferedReader(ne...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
cf01aff961270f6677d6b913a00190bc
train_002.jsonl
1581518100
You have a bag of size $$$n$$$. Also you have $$$m$$$ boxes. The size of $$$i$$$-th box is $$$a_i$$$, where each $$$a_i$$$ is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.For example, if $$$n = 10$$$ and $$$a = [1, 1, 32]$$$ then you hav...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.TreeMap; import java.util.Map; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at t...
Java
["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8"]
2 seconds
["2\n-1\n0"]
null
Java 11
standard input
[ "bitmasks", "greedy" ]
79440d6707a1d7553493130ebced47e3
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{18}, 1 \le m \le 10^5$$$) — the size of bag and the number of boxes, respectively. The second line of each test case contains $$...
1,900
For each test case print one integer — the minimum number of divisions required to fill the bag of size $$$n$$$ (or $$$-1$$$, if it is impossible).
standard output
PASSED
2061dc85871d1f9814884e33cabb1516
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.util.*; import java.io.*; public class Task{ // taking inputs static BufferedReader s1; static BufferedWriter out; static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;} static int int_v (String s1){return Integer.parseInt(s1);} static lon...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
1bbe54ada73edaac3de5f42772a6e595
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.util.*; public class Codeforces1 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] arr = new int[n]; HashMap<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < n; i++) { arr[i] = s.nextInt(); map.put(arr[i], map.getOrDefaul...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
1cdc795464de8f1589567d43dc521d14
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] a = new int[100001]; List<Integer> p2 = new ArrayList<Integer>(); List<Integer> p4 = new ArrayList<Integer>(); ...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
7ed0ef2715e5868598ace9676d80457d
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] a = new int[100001]; Set<Integer> p2 = new HashSet<Integer>(); Set<Integer> p4 = new HashSet<Integer>(); Set<I...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
8544228e9b896ff169d9d3117738f658
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.util.*; public class MyClass { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for(int i=0;i<n;i++) { a[i] = sc.nextInt(); } int k = sc.nextInt(); HashMap<Integer,Integ...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
47464c80ea572ddca351fecc15fc238e
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.util.*; import java.io.*; public class tr0 { static PrintWriter out; static StringBuilder sb; static int mod = 1000000007; static long inf = (long) 1e16; static int[] l, r; static int n, m, k; static long all, ans; static ArrayList<Integer>[] ad; static long[][] memo; static boolean f; static bo...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
0c6aa75b56d4e761e504cef900dfed26
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); HashSet<Integer>g8=new HashSet<Integer>(); HashSet <Integer> g6=new HashSet<Integer>(); HashSet<I...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
290f1edfb3f5ba8b3f25a7ddb40baf37
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class B { static class Pair implements Comparable<Pair> { int f, s; Pair(int f, int s){this.f = f;this.s = s;} public int compareTo(Pair b){return Integer.compare(b.s,this.s);} } public static void main(String[]...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
bae3a3ea4c8ccbf5bdce32f77f03e7eb
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ public static Scanner scn=new Scanner(new InputStreamReader(System.in)); public static void main(String[]args){ int n=scn.nextInt(); ArrayList<Integer>arr=new ArrayList<>(); HashMap<Integer,Integer>map=new HashMap<>(); ...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
b4e029846502edd81657da275cf650ca
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.util.*; import java.io.*; public class bitch{ public static Scanner scn=new Scanner(new InputStreamReader(System.in)); public static void main(String[]args){ int n=scn.nextInt(); ArrayList<Integer>arr=new ArrayList<>(); HashMap<Integer,Integer>map=new HashMap<>(); Has...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
abd137697cf31a13a669fb4687f3e0bc
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.io.InputStream; import java.io.BufferedReader; import java.io.PrintWriter; import java.io.InputStreamReader; import java.io.IOException; import java.util.*; public class AppleStore { public static void main(String[] args) throws IOException { InputReader in = new InputReader(System.in); PrintWrit...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
3888d47b5862abb07b8ff6589ec37116
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.util.Scanner; /** * @author Carry * @date 2020/11/15 */ public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int n = sc.nextInt(); int cnt4 = 0; int cnt2 = 0; int[] cnt = new int[100_000 + 1]; for...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
25e4204d208581c8d966e679ebf1c6de
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStrea...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
d11c7cb3228138579c093a85728917b9
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.util.*; import java.io.*; public class ApplejackandStorages2 { // https://codeforces.com/contest/1393/problem/B public static void main(String[] args) throws IOException, FileNotFoundException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); //BufferedReader in = new Bu...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
11a66bfccd7bce967e94824844e5d37a
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; /** * @author hypnos * @date 2020/11/13 */ public class Main2 { public static void main(String[] args) throws IOException { // Scanner sc = new Scanner(System.in)...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
af8cf246969bd5e14514c8eecc15e068
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.util.Scanner; /** * @author hypnos * @date 2020/11/13 */ public class test { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int i; int[] a = new int[100001]; int[] c = new int[100001]; for (i = 0; ...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
05ae0b93df64adda904155168ed6d59e
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int[] ar=new int[100001]; int n=Integer.parseInt(br.readLine()); String[] str=br.readLine...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
c4e51656189671d237723ca3034baba0
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.StringTokenizer; /** * @author b * */ public class B {...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
d57042499101eba6013ecabc8e8086f7
train_002.jsonl
1596810900
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).App...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class CodeForce_662 { public static void main(String[] args) throws IOException { FastScanner sc = new FastScanner(); PrintWriter pw = new PrintWriter(System.out); ...
Java
["6\n1 1 1 2 1 1\n6\n+ 2\n+ 1\n- 1\n+ 2\n- 1\n+ 2"]
2 seconds
["NO\nYES\nNO\nNO\nNO\nYES"]
NoteAfter the second event Applejack can build a rectangular storage using planks with lengths $$$1$$$, $$$2$$$, $$$1$$$, $$$2$$$ and a square storage using planks with lengths $$$1$$$, $$$1$$$, $$$1$$$, $$$1$$$.After the sixth event Applejack can build a rectangular storage using planks with lengths $$$2$$$, $$$2$$$, ...
Java 8
standard input
[ "data structures", "constructive algorithms", "implementation", "greedy" ]
d14bad9abf2a27ba57c80851405a360b
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$): the initial amount of planks at the company's storehouse, the second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^5$$$): the lengths of the planks. The third line contains a single integer $$$q$$$ ($$$1 \le q \...
1,400
After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).
standard output
PASSED
c680d81c666ab9fcf5af6c6a3dba784c
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.io.*; import java.util.*; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class Main implements Runnable { static boolean use_n_tests = true; static int stack_size = 1 << 27; void solve(FastScanner in, PrintWriter out, int testNumber) { int n = in.nextInt();...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
dca51a14e34cddbd4294f384149a89a5
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class T3 extends PrintWriter { public T3() { super(System.out); } public static void main(String[] args) { Scanner s = new Scanner(System.in); T3 main = new T3(); int n = s.nextInt(); ...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
51512de6ce7938e1dae9f6a27ff1923c
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; public class PokemonArmy { public static void main(String[] args) { Scanner in = new Scanner (System.in); int t = in.nextInt(); for (int i=0; i<t; i++) { int n = in.nextInt(); in.nextInt(); long [] arr = new long [n]; for (int j=0; j<n; j++) { arr[j] = in.nextLong(); ...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
0ec9c5abae8e904fe39ae6fd8db13d61
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; public class hundredsixtyfive { public static void main(String[] args) { int t; Scanner sc=new Scanner(System.in); t=sc.nextInt(); while(t-->0) { int n,q; n=sc.nextInt(); q=sc.nextInt(); int a[]=new int[n...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
199960109aa020373763c8fc30225717
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
// "static void main" must be defined in a public class. import java.util.Scanner; public class Main { private static long f(int index,int neg,int[] a){ if(index >= a.length)return 0; if(dp[index][neg] != null)return dp[index][neg]; long max = Long.MIN_VALUE; if(neg == 0){ ...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
001df76c9001e986877f07fc44ddc86c
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
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.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeSet; public class R672 { static in...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
10b98e4b46e325ef250970be7a10f5c1
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
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.ArrayList; import java.util.StringTokenizer; import java.util.TreeSet; public class R672 { public static void main(String[] a...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
87a9b841a9c0828c25a8b6fcb2a1e082
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; public class Main { static long dp[][]=new long [300005][2]; static Scanner sc=new Scanner(System.in); public static void main(String[] args) { int n=sc.nextInt(); for(int i=0;i<n;i++) { show(); } } static void show() { int n=sc.ne...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
f0e261dca5115515fcfa33e5ffe566dc
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; public class Main { static long dp[][]=new long [300005][2]; static Scanner sc=new Scanner(System.in); public static void main(String[] args) { int n=sc.nextInt(); for(int i=0;i<n;i++) { show(); } } private static void show() { int ...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
ab0e23a8cd59117de4b16fd9cfd58671
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; import java.io.*; public class pokeeasy { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int t = Integer.parseInt(in.readLine()); for(int i = 0; i < t; i++) {...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
0e8c21a2f320b3f3e41185fe6c6eeabd
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.awt.Point; // SHIVAM GUPTA : //NSIT //decoder_1671 // STOP NOT TILL IT IS DONE OR U DIE . // U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE................ // ASCII = 48 + i ;// 2^28 = 268,435,456 > 2* 10^8 // log 10 base 2 = ...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
54dc2d87db930a3518c2fca8c2cebcd0
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.awt.Point; // SHIVAM GUPTA : //NSIT //decoder_1671 // STOP NOT TILL IT IS DONE OR U DIE . // U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE................ // ASCII = 48 + i ;// 2^28 = 268,435,456 > 2* 10^8 // log 10 base 2 = ...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
2ff81e6acef266b6527cb285d778d2f3
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class P672C1 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int i = 0; i < t; i++) { solve(in); } } private static void s...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
1d1c19d8786ca4e86f4547320d218fb0
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCha...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
072560ff30e04fefeb8ea3042c9d99bd
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; import java.io.*; public class MyClass { static PrintWriter w; public static void main(String args[]) { Scanner sc = new Scanner(System.in); w=new PrintWriter(System.out); int test=Integer.parseInt(sc.nextLine()); A: while(test-->0){ ...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
adf1c7d6da88759d9681b0ed1320e27e
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
// package programs; import java.util.*; import static java.lang.System.out; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { static final long mod = (int)1e9+7; static final long M = (int)1e9+7; static cl...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
b34932c2272805994ede516e878f5367
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int q=0;q<t;q++) { int n=sc.nextInt(); int k=sc.nextInt(); int arr[]=new int[n]; for(int i=0...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
465f922150480710acd78b835d25ee35
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; public class solution1 { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); for(int tt=0;tt<t;tt++) { int n=s.nextInt(); int q=s.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) { a[i]=s.nextInt(); } long ans=a[0]; for(in...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
9a8a09b44401c2351faf06c1bb84ec82
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new Dat...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
0b50c285887832c62a704121ad73ff5c
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.Scanner; public class dp { public static void main(String args[]) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while (t-- > 0) { int n = scn.nextInt(); int q = scn.nextInt(); int[] arr = new int[n]; for (i...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
63cdfaf8fd2a17377c0cedb4b725ee77
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; public class sex { public static void main (String args[]){ Scanner s = new Scanner(System.in); int T = s.nextInt(); for(int ii=0;ii<T;ii++){ int n = s.nextInt(); int q=s.nextInt(); int [] a = new int [n]; for(int j=0;j<n;j++){ a[j]=s.nextInt();...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output
PASSED
d8dd671147ae580ccccadd1e850b469e
train_002.jsonl
1600958100
This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.Pikachu is a cute and friendly pokémon living in the wild pikachu herd.But it has become known recently that infamous team R wan...
256 megabytes
import java.util.*; public class MAIN1 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int q=sc.nextInt(); int[] a=new int[n+2]; boolean ans=false; for(int i=1;i<=n;i++) { a[i]=sc.nextInt(); } a[n+1]=0;...
Java
["3\n3 0\n1 3 2\n2 0\n1 2\n7 0\n1 2 5 4 3 6 7"]
2 seconds
["3\n2\n9"]
NoteIn third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be $$$5−3+7=9$$$.
Java 11
standard input
[ "dp", "constructive algorithms", "greedy" ]
2d088e622863ab0d966862ec29588db1
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$) denoting the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 3 \cdot 10^5, q = 0$$$) denoting the ...
1,300
For each test case, print $$$q+1$$$ integers: the maximal strength of army before the swaps and after each swap.
standard output