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
ab20fa42c48f581a3406d6a4829d6978
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 > 1$$$ and $$$d_2 > 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.util.*; import java.io.*; import java.lang.Math; import java.util.Random; public class Solution{ static int max = (int)(1e7); static int[] minDiv; public static void main(String[] args) throws Exception{ FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 > 1$$$ and $$$d_2 > 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
5bf67e49c0b8ffa959daaaeb73848675
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 > 1$$$ and $$$d_2 > 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.*; public class cf1366d { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); boolean[] seive = new boolean[10000001]; int[] div = new int[10000001]; for (int i=2;i*i<=seive.length;i++)...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
0903f2c5863607a311849186a0db47f6
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { int mod1=(int)1e9+7; int mod2=998244353; public void solve() throws Exception { // int t=sc.nextInt(); // while(t-->0) // ...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
e2a59c2122d01f04bd782ad1737a9858
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner s=new Scanner(System.in); int N=Integer.parseInt(s.nextLine()); int[] ans1=new int[N]; int[] ans2=new int[N]; for(int i=0;i<N;i++){ int[] l=help(s); ans1[i]=l[0];...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
45d3ec1d44225753e085790bd5e8bb68
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { FastScanner s=new FastScanner(); PrintWriter out = new PrintWriter(System.out); int N=In...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
259cec23beff1e2c1493f906411e8891
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
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.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class Sol...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
698ede9944d1f9ceb475493fb584155d
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.math.*; import java.io.*; import java.util.*; import java.awt.*; public class Main implements Runnable { @Override public void run() { try { new Solver().solve(); System.exit(0); } catch (Exception | Error e) { e.printStackTrace(); Sys...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
9d188e0c0d8f2d9fe65f71b44548fb18
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.awt.Point; // SHIVAM GUPTA : //NSIT //decoder_1671 //BEING PERFECTIONIST IS NOT AN OPTION. // STOP NOT TILL IT IS DONE OR U DIE . //EITHER MAKE IT OR BREAK IT. //NEVER UNDERESTIMATE URSELF. // U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFE...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
4fa76e23757ed23c9dc5b0c1924e1b3a
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
// upsolve with kaiboy, coached by rainboy import java.io.*; import java.util.*; public class CF1366D extends PrintWriter { CF1366D() { super(System.out); } static class Scanner { Scanner(InputStream in) { this.in = in; } InputStream in; int k, l; byte[] bb = new byte[1 << 15]; byte getc() { if (k >= l) { ...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
3c326428503b1d0875f85e0726436aea
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); U...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
df68e30cae4f39bcec5a01ebe6d3291d
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.*; import java.util.*; public class Main{ static int[]lp; static void sieveLinear(int N) { ArrayList<Integer> primes = new ArrayList<Integer>(); lp = new int[N + 1]; //lp[i] = least prime divisor of i for(int i = 2; i <= N; ++i) { if(lp[i] == 0) { primes.add(i); lp[i] = i...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
551afe9cbac495409ccd0060938086d1
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.*; import java.security.SecureRandom; import java.util.*; import java.util.stream.*; public class D1366 { // 420 remainder: use long everywhere private final static boolean MULTIPLE_TESTS = false; private final static int MAX_N = 10_000_000; private void solve() { int[] smal...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
76fbf4b595dc4aa275d2fbbb35bc0d22
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelp...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
a498032f94d35a02c297daf8f9a71927
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class test { static int sf[]; public static void main(String[] args) { // int test = fs.nextInt(); int test = 1; // int t = fs.nextInt(); sieve(); for (int cases = 0; cases < test; cases++) { int n = fs.nextInt(); int ar[] = getintarray...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
cfd33d099d5aaae24a6ea19e66c946db
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.*; public class Main { static long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } public static void main(String args[]) throws IOException { FastReader in = new FastReader(Sys...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
120bc9edc10f0677b84e925bb0ec70f2
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; /** * @author Tran Anh Tai * @template for CP codes */ public class ProbD { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new Inp...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
5489cf573c1ec4f0e7dd7272e1b8bee9
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
/* package codechef; // don't place package name! */ import java.lang.*; import java.io.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; /* Name of the class has to be "Main" only if the class is public. */ public clas...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
7a4ad5ea7415a3793267f4038f0305ba
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class D_Two_Divisors { static int[] minDiv; static ArrayList<In...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
5a5e5bc0d06ed91e49e7f827b846d239
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.util.Scanner; public class twoDivisors { static int div[] = new int[10000001]; static void findDiv() { for (int i = 2; i <= Math.sqrt(div.length); i++) if (div[i] == 0) for (int j = i * i; j < div.length; j = j + i) if (div[j] == 0) div[j] = i; } public static void main(String[] a...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
d5ce4e99d7e8bbedf74abdce3aa915c1
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.*; import java.util.*; public class A { static int minPrime(int x) { for (int p : primes) { if (p * p > x) break; int d = 1; while (x % p == 0) { x /= p; d *= p; } if (d > 1) return d; } return x; } static ArrayList<Integer> primes; public static void main(S...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
573d4d9a835c1edff9cf48715538b5af
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.util.*; import java.io.*; public class I { private int[] minDiv; public I(FastScanner in, PrintWriter out) { minDiv = new int[(int)1e7 + 1]; for (int i = 2; i < minDiv.length; i++) { if (minDiv[i] == 0) { minDiv[i] = i; for (int j = 2 *...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
c80645973a4d8394d7592c9f05659261
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.util.*; import java.io.*; public class I { private int[] minDiv; public I(FastScanner in, PrintWriter out) { minDiv = new int[(int)1e7 + 1]; for (int i = 2; i < minDiv.length; i++) minDiv[i] = i; int bound = (int)Math.sqrt(minDiv.length - 1); for (int...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
9fdd42ebf91b3ffa6d0a6042053aab80
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
8799f1dcd3c89aa45b65516186bca292
train_002.jsonl
1591886100
You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$.For each $$$a_i$$$ find its two divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ (where $$$\gcd(a, b)$$$ is the greatest common divisor of $$$a$$$ and $$$b$$$) or say that there is no such pair.
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class D { static final boolean RUN_TIMING = false; static char[] inputBuffer = new char[1024]; static PushbackReader in = new PushbackReader(new BufferedReader(new InputStreamReader(System.in)), 1024); static PrintWriter out = new PrintWr...
Java
["10\n2 3 4 5 6 7 8 9 10 24"]
2 seconds
["-1 -1 -1 -1 3 -1 -1 -1 2 2 \n-1 -1 -1 -1 2 -1 -1 -1 5 3"]
NoteLet's look at $$$a_7 = 8$$$. It has $$$3$$$ divisors greater than $$$1$$$: $$$2$$$, $$$4$$$, $$$8$$$. As you can see, the sum of any pair of divisors is divisible by $$$2$$$ as well as $$$a_7$$$.There are other valid pairs of $$$d_1$$$ and $$$d_2$$$ for $$$a_{10}=24$$$, like $$$(3, 4)$$$ or $$$(8, 3)$$$. You can pr...
Java 11
standard input
[ "constructive algorithms", "number theory", "math" ]
8639d3ec61f25457c24c5e030b15516e
The first line contains single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the size of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 10^7$$$) — the array $$$a$$$.
2,000
To speed up the output, print two lines with $$$n$$$ integers in each line. The $$$i$$$-th integers in the first and second lines should be corresponding divisors $$$d_1 &gt; 1$$$ and $$$d_2 &gt; 1$$$ such that $$$\gcd(d_1 + d_2, a_i) = 1$$$ or $$$-1$$$ and $$$-1$$$ if there is no such pair. If there are multiple answe...
standard output
PASSED
2eb2f9163d8fa560b2c6d00cc1d4b073
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class test{ public static void main(String... args) throws NumberFormatException, IOException{ BufferedReader br=new BufferedReader(new InputStream...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
2e250afa09b923e456ae56be176f8a88
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.ArrayList; import java.io.InputStream; import java.io.IOException; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { //input data Scanner s = new Scanner(System.in); int n = s.nextInt(); ...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
36862f068a505de7fa2d535bce15c6dd
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.ArrayList; import java.io.InputStream; import java.io.IOException; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { //Main idea: run 2 pointers on the round requirement list and prepared problem list ...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
2c2eaea4ebe334ad4a55c927bcba9950
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.Scanner; public class GeorgeAndRound { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); int a[]=new int[n]; int b[]=new int[m]; for(int i=0;i<n;i++) a[i]=sc.nextInt(); for(int i=0;i<m;i++) b[i]=sc.nextInt(); int ...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
2121d56b27d50c49478cca21c27fa61c
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.Scanner; public class George { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); int a[]=new int[n]; int b[]=new int[m]; for(int i=0;i<n;i++) a[i]=sc.nextInt(); for(int i=0;i<m;i++) b[i]=sc.nextInt(); int j=0,coun...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
7a5f45e3937c67df719fc5b9753a3aa9
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Solution { public static void main (String[] args) throws java.lang.Exception { // your code goes here ...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
950cd2e5336fee8f9e3daf4d9c009384
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.TreeMap; public class codeForce_387B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); List<Integer> A = new ArrayLi...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
eb8d8d4d6b39b9ba65a19027c08ea1e4
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.io.IOException; import java.util.InputMismatchException; /** * Created by jizhe on 2015/12/25. */ public class GeorgeAndRound { public static class FasterScanner { private byte[] buf = new byte[1024]; private int curChar; private int numChars; public int read() { ...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
7b0c2b29a32934396d73ec88b6ebb7f6
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Map; import java.util.PriorityQueue; import java.util.Scanner; import ja...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
882eac5b212f0152e704840d4a7b43ad
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.Scanner; /** * * @author thachlp */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = ...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
f85cd4e39132595dd51851e38e453f29
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.Scanner; /** * * @author thachlp */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = ...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
4d1da41cbfe5de90ad221a5131ff9c67
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.Arrays; import java.util.HashSet; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int m = s.nextInt(); int arr1[] = new int[n]; int arr2[] =...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
b1e23ec203f83947b7ecfdc4431783f8
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.Arrays; import java.util.HashSet; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int m = s.nextInt(); int arr1[] = new int[n]; int arr2[] =...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
c33ac3f872442b125be9c76edd7bc34e
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class Ex1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); ArrayList<Integer> arr1 = new ArrayList<>(); ArrayList<Integer> arr2 = new ArrayList<>(); for (int i = 0; i < n...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
1b603dcf62ac9742bf6bfa9abe574a38
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
//package com.prituladima.codeforce.a2oj.div2B; import javax.print.attribute.IntegerSyntax; import java.io.*; import java.lang.reflect.Array; import java.util.*; import static java.lang.Double.parseDouble; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.util.Array...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
e9911bcdf3c1832dd49d578e5d8c5b98
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.concurrent.ThreadLocalRandom; import java.io.Writer; import java.io.OutputStreamWriter; import java.util....
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
8b36f6b8be3856bf2b95672061ed4edc
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.*; // */ //package pkgimport; /** * * @author mac */ public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String line1 = in.nextLine(); String line2 = in.nextLine(); String line3 = in.nextLine(); String[] va...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
3aabec6833c035501602a4256f38c975
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.Scanner; /** * Created by anhtran on 5/30/17. */ public class George387B { public static int getMinProbNum(int n, int m, int[] require, int[] prep) { // int[] freq = new int[3000+1]; // for(int i = 0; i < prep.length; i++){ // freq[prep[i]]++; // } // int ...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
b7196e068304de19b284ce6d4b8d94fb
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.*; public class Main{ private void solve() throws Exception{ int[] in = ria(2); int n = in[0], m = in[1]; int[] a = ria(...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
9c4330f6f5391e6561483fd0efc27c6d
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.io.PrintStream; import java.util.Scanner; public class GeorgeAndRound { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintStream out = new PrintStream(System.out); String[] inputs = in.nextLine().split(" "); int goodRoundProblemSize = Integer.valueOf(inp...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
540f31617c7d3fa430be5f9ca80fe199
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
/* * Idea: * - Create 2 arrays: one for the complexities of the problems George has already prepared (prepared[]), * one for the complexities of the problems required (required[]) to make a good round. * - Originally, number of new problems needed n = number of problems required. * - Since both required[] and pre...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
4d6fb26953928906859f0d61da4694cc
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.Scanner; public class HW1 { public static void main (String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int m = scanner.nextInt(); int a[] = new int[1000001]; int b[] = new int[1000001]; for (int i = 0; i < n; ...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
cecbac7a4ddb1e0b26584edfb7977f3e
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
3af8a00113f69cdd0a4a451a8afb8332
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
/* Author LAVLESH */ import java.util.*; import java.io.*; public class solution { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st=new StringTokenizer(""); static public String next() { while (st == null || !st.hasMoreTokens()) { try...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
970f4fbf90c64ae1b94818863f11975d
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int need = sc.nextInt(); int prep = sc.nextInt(); sc.nextLine(); ArrayList<Integer> needList = new Arr...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
db17e445f10ad80c34d4a56ef34d5cb3
train_002.jsonl
1391095800
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem w...
256 megabytes
import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Bai1_387B_GeorgeandRound { /*https://codeforces.com/problemset/problem/387/B*/ public static void main(String[] args) { /* * m problems for the round (mark from 1 to m) * round good => put at least...
Java
["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1"]
1 second
["0", "2", "3"]
NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems wi...
Java 8
standard input
[ "two pointers", "greedy", "brute force" ]
bf0422de4347a308d68a52421fbad0f3
The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 &lt; a2 &lt; ... &lt; an ≤ 106) — the requirements for the complexity of the problems in...
1,200
Print a single integer — the answer to the problem.
standard output
PASSED
103a306d1148fb96762f4d51d893abbf
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
//package src; import java.util.Scanner; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.PriorityQueue; import java.util.Queue; import java.util.Stack; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.Vector; import java.util.ArrayList; import...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
ec9981593033a8934ef173e05550618c
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
// Nice question revise this import java.util.*; import java.io.*; public class lp{ static PrintWriter out = new PrintWriter(System.out); static boolean ok(int len,int k,int p[]){ int i1=0,i2=len-1; while(i2<p.length){ int sum = p[i2]; if(i1>0) sum = ...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
b35895f7de1ff481ab889ef8ebaa0be8
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
/* Keep solving problems. */ import java.util.*; import java.io.*; public class CF660C { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; final long MOD = 1000L * 1000L * 1000L + 7; void solve() throws IOException { int n = nextInt(); int k = nextInt(); ...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
0d990e6d92a386f25b813d04a2175768
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int[] values = new int[n]; for (int i = 0; i < n; i++) { values[i] = in.nextInt(); } int left = 0; int righ...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
e44d60c6de2da8ba6ce049f53f2431c0
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class WorkFile { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(), k = s.nextInt(); StringBuilder array = new StringBuilder(); ArrayList<Integer> list = new ArrayList<>(); ...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
4bb94e151193f808f7f4d22e05fecd9e
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
// No sorceries shall prevail. // import java.util.*; import java.io.*; public class InVoker { static long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } static int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a %...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
9537d2f96a335e5b300cddcaa3667ac5
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class cf { static int n; static int k; static int arr[]; public static void main(String args[]) { PrintWriter out=new PrintWriter(System.out); Scanner sc = new Scanner(System.in); n= sc.nextInt(); k=sc.n...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
c0c22b3fc25471261d59147d0f5eef39
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args) { InputReader in = new InputReader(System.in); OutputWriter out = new OutputWriter(System.out); int n = in.nextInt(); int[] a= new int[n]; int k = in.nextInt(); for (int i ...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
628de6d0a7d02a3f0039ecde79d3031f
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Solution { static final int MAX_INT = 1000000; public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = ne...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
92f48da1eae1a846e5b91b21481d3b10
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Solution { static final int MAX_INT = 1000000; public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = ne...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
5858a21cb751b1093e916a55d67af842
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
// package stupiddog; import java.io.*; import java.lang.*; import java.util.*; /** * * @author Huynh Sam Ha - BKU - VN - 1610852@hcmut.edu.vn * @author Stupid - Dog * */ public class StupidDog { public static void main(String[] args) throws IOException { inputSystem = new InputStreamReader(System.i...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
d2a21b6d1cdce75ea780d2f91ea62a34
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.io.*; import java.util.*; public class qwe { static FastScanner in = new FastScanner(); //static PrintWriter ww = new PrintWriter(new OutputStreamWriter(System.out)); //static PrintWriter pw = new PrintWriter(System.out); //pw.print();pw.println();pw.printf(); public static void main(String[] args)...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
3124d0b7c8f4c27a700a234c90897e89
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; ...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
41dacd6317faf132ec3d2117166053e4
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.stream.Collectors; /** * C. Hard Process * */ public class D2C { public static void main(String args[] ) throws IOE...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
68a3fa9cb5d6ae585812ce8d7cffba6e
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Solution{ public static void main(String[] args){ try { PrintWriter out=new PrintWriter(System.out,true); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String[]...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
f293576aaa8c302cab4df79a6cb20c58
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.util.Scanner; public class HardProcess4 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); boolean[] a = new boolean[n]; int[] s = new int[n]; // boolean debug = false; int[] zeroindexes = new int[n]; int whic...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
5cfb3633c7c127c62b00c4fd36626a67
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.io.*; import java.util.*; public class hard_process { public int advanceL(int []a, int l) { for (int i = l; i< a.length; i++) { if (a[i]==0) return(i+1); } return(0); } public void printSequence(int[] a, int l_max, int r_max, int k) { int n = a.length; StringBuilder ans = new ...
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
d6914d2e9f0dcd1c1f15bf24138fcefa
train_002.jsonl
1460127600
You are given an array a with n elements. Each element of a is either 0 or 1.Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class CFC { public static void main(String[] args) throws IOException { FastScanner9 in = new FastScanner9(); PrintWriter out = new PrintWriter(System....
Java
["7 1\n1 0 0 1 1 0 1", "10 2\n1 0 0 1 0 1 0 1 0 1"]
1 second
["4\n1 0 0 1 1 1 1", "5\n1 0 0 1 1 1 1 1 0 1"]
null
Java 8
standard input
[ "dp", "two pointers", "binary search" ]
ec9b03577868d8999bcc54dfc1aae056
The first line contains two integers n and k (1 ≤ n ≤ 3·105, 0 ≤ k ≤ n) — the number of elements in a and the parameter k. The second line contains n integers ai (0 ≤ ai ≤ 1) — the elements of a.
1,600
On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones. On the second line print n integers aj — the elements of the array a after the changes. If there are multiple answers, you can print any one of them.
standard output
PASSED
cd9ebc7564128ecee3cdc1acbee33295
train_002.jsonl
1566484500
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { static long t, n, a, b; static String s; static long[][][] memo; public static long dp(int indx, int height, int next) { if(indx == n - 1) return (height + 1) * b + (height == 2 ? 2 * a : a); if(memo[indx]...
Java
["4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00"]
2 seconds
["94\n25\n2900000000\n13"]
NoteThe optimal pipeline for the first query is shown at the picture above.The optimal pipeline for the second query is pictured below: The optimal (and the only possible) pipeline for the third query is shown below: The optimal pipeline for the fourth query is shown below:
Java 11
standard input
[ "dp", "greedy" ]
4fa609ef581f705df901f7532b52cf7c
The fist line contains one integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2 \cdot T$$$ lines contain independent queries — one query per two lines. The first line contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$1 \le a \le 10^8$$$, $$$1 \le b \le 10^8$$$) ...
1,500
Print $$$T$$$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.
standard output
PASSED
5953b8e24b17ae40e33e3be82e5fd0ee
train_002.jsonl
1566484500
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf1207c { public static void main(String[] args) throws IOException { int t = ri(); while (t --> 0) { int n = rni(), a = ni(), b = ni(), c[] = new int[n]; c...
Java
["4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00"]
2 seconds
["94\n25\n2900000000\n13"]
NoteThe optimal pipeline for the first query is shown at the picture above.The optimal pipeline for the second query is pictured below: The optimal (and the only possible) pipeline for the third query is shown below: The optimal pipeline for the fourth query is shown below:
Java 11
standard input
[ "dp", "greedy" ]
4fa609ef581f705df901f7532b52cf7c
The fist line contains one integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2 \cdot T$$$ lines contain independent queries — one query per two lines. The first line contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$1 \le a \le 10^8$$$, $$$1 \le b \le 10^8$$$) ...
1,500
Print $$$T$$$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.
standard output
PASSED
719a538347a3c155cbef15a3e9695a87
train_002.jsonl
1566484500
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Rextester{ public static void main(String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); StringBuffer sb = new StringBuffer()...
Java
["4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00"]
2 seconds
["94\n25\n2900000000\n13"]
NoteThe optimal pipeline for the first query is shown at the picture above.The optimal pipeline for the second query is pictured below: The optimal (and the only possible) pipeline for the third query is shown below: The optimal pipeline for the fourth query is shown below:
Java 11
standard input
[ "dp", "greedy" ]
4fa609ef581f705df901f7532b52cf7c
The fist line contains one integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2 \cdot T$$$ lines contain independent queries — one query per two lines. The first line contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$1 \le a \le 10^8$$$, $$$1 \le b \le 10^8$$$) ...
1,500
Print $$$T$$$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.
standard output
PASSED
bb01c25468fe80fd32edc03686dc2ab4
train_002.jsonl
1566484500
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as...
256 megabytes
import java.io.*; import java.util.*; public class Main { private void solve()throws IOException { int n=nextInt(); int a=nextInt(); int b=nextInt(); long ans=0; String s=nextLine(); int i=0; boolean first=true; while(i<n) if(s.charAt(i)=='1') { int trail=0; while(s.charAt(i)=='1') ...
Java
["4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00"]
2 seconds
["94\n25\n2900000000\n13"]
NoteThe optimal pipeline for the first query is shown at the picture above.The optimal pipeline for the second query is pictured below: The optimal (and the only possible) pipeline for the third query is shown below: The optimal pipeline for the fourth query is shown below:
Java 11
standard input
[ "dp", "greedy" ]
4fa609ef581f705df901f7532b52cf7c
The fist line contains one integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2 \cdot T$$$ lines contain independent queries — one query per two lines. The first line contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$1 \le a \le 10^8$$$, $$$1 \le b \le 10^8$$$) ...
1,500
Print $$$T$$$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.
standard output
PASSED
1c5228743e7a24ef983cee9df91729f9
train_002.jsonl
1566484500
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as...
256 megabytes
import java.util.*; public class GasPipeline { public static void main(String[] args) { Scanner s = new Scanner(System.in); int tc = s.nextInt(); for (int t = 0; t < tc; t++) { int n = s.nextInt(); long a = s.nextLong(), b = s.nextLong(); char[] cs = s.n...
Java
["4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00"]
2 seconds
["94\n25\n2900000000\n13"]
NoteThe optimal pipeline for the first query is shown at the picture above.The optimal pipeline for the second query is pictured below: The optimal (and the only possible) pipeline for the third query is shown below: The optimal pipeline for the fourth query is shown below:
Java 11
standard input
[ "dp", "greedy" ]
4fa609ef581f705df901f7532b52cf7c
The fist line contains one integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2 \cdot T$$$ lines contain independent queries — one query per two lines. The first line contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$1 \le a \le 10^8$$$, $$$1 \le b \le 10^8$$$) ...
1,500
Print $$$T$$$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.
standard output
PASSED
48039cf509b6069410376d404409a10b
train_002.jsonl
1566484500
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as...
256 megabytes
import java.io.*; import java.util.*; public class GasPipe { static Reader sc=new Reader(); static PrintWriter out=new PrintWriter((System.out)); public static void main(String args[])throws IOException { int t=sc.nextInt(); while(t-->0) { solve(); } out.close(...
Java
["4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00"]
2 seconds
["94\n25\n2900000000\n13"]
NoteThe optimal pipeline for the first query is shown at the picture above.The optimal pipeline for the second query is pictured below: The optimal (and the only possible) pipeline for the third query is shown below: The optimal pipeline for the fourth query is shown below:
Java 11
standard input
[ "dp", "greedy" ]
4fa609ef581f705df901f7532b52cf7c
The fist line contains one integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2 \cdot T$$$ lines contain independent queries — one query per two lines. The first line contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$1 \le a \le 10^8$$$, $$$1 \le b \le 10^8$$$) ...
1,500
Print $$$T$$$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.
standard output
PASSED
a90e8f398ae2af13ac5dd47b0bac4c04
train_002.jsonl
1566484500
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as...
256 megabytes
import java.io.*; import java.util.*; /** * Built using my Brain * Actual solution is at the bottom * * @author Lenard Hoffstader */ public class cfjava { public static void main(String[] args) { OutputStream outputStream = System.out; FastReader in = new FastReader(); PrintWriter out = new Pr...
Java
["4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00"]
2 seconds
["94\n25\n2900000000\n13"]
NoteThe optimal pipeline for the first query is shown at the picture above.The optimal pipeline for the second query is pictured below: The optimal (and the only possible) pipeline for the third query is shown below: The optimal pipeline for the fourth query is shown below:
Java 11
standard input
[ "dp", "greedy" ]
4fa609ef581f705df901f7532b52cf7c
The fist line contains one integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2 \cdot T$$$ lines contain independent queries — one query per two lines. The first line contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$1 \le a \le 10^8$$$, $$$1 \le b \le 10^8$$$) ...
1,500
Print $$$T$$$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.
standard output
PASSED
ca64ab9508cfdcef8594ea17e32d3dd9
train_002.jsonl
1566484500
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as...
256 megabytes
import java.io.*; import java.util.*; import java.lang.Math; public class GasPipeline { public static void main (String [] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); int ttttt = Integer.parseInt(f.readLine()); for(int aaa = 0; aaa < ttttt; aaa+...
Java
["4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00"]
2 seconds
["94\n25\n2900000000\n13"]
NoteThe optimal pipeline for the first query is shown at the picture above.The optimal pipeline for the second query is pictured below: The optimal (and the only possible) pipeline for the third query is shown below: The optimal pipeline for the fourth query is shown below:
Java 11
standard input
[ "dp", "greedy" ]
4fa609ef581f705df901f7532b52cf7c
The fist line contains one integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2 \cdot T$$$ lines contain independent queries — one query per two lines. The first line contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$1 \le a \le 10^8$$$, $$$1 \le b \le 10^8$$$) ...
1,500
Print $$$T$$$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.
standard output
PASSED
9f2f9f54c5748ede26dc84ae456f324b
train_002.jsonl
1566484500
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as...
256 megabytes
import java.io.*; import java.util.*; public class cf{ public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); int t = Integer.parseInt(bf.readL...
Java
["4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00"]
2 seconds
["94\n25\n2900000000\n13"]
NoteThe optimal pipeline for the first query is shown at the picture above.The optimal pipeline for the second query is pictured below: The optimal (and the only possible) pipeline for the third query is shown below: The optimal pipeline for the fourth query is shown below:
Java 11
standard input
[ "dp", "greedy" ]
4fa609ef581f705df901f7532b52cf7c
The fist line contains one integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2 \cdot T$$$ lines contain independent queries — one query per two lines. The first line contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$1 \le a \le 10^8$$$, $$$1 \le b \le 10^8$$$) ...
1,500
Print $$$T$$$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.
standard output
PASSED
5e605c862ac06e64137c533da575644a
train_002.jsonl
1566484500
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as...
256 megabytes
import java.io.*; import static java.lang.Double.*; import java.util.*; public class Mao { static Reader in=new Reader (); static long ans,mz=0,mx=0; static int a[],b[]; static StringBuilder sd=new StringBuilder(); public static void main(String [] args) { int t=in.nextInt(); while(t-->0){mz=0;mx=...
Java
["4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00"]
2 seconds
["94\n25\n2900000000\n13"]
NoteThe optimal pipeline for the first query is shown at the picture above.The optimal pipeline for the second query is pictured below: The optimal (and the only possible) pipeline for the third query is shown below: The optimal pipeline for the fourth query is shown below:
Java 11
standard input
[ "dp", "greedy" ]
4fa609ef581f705df901f7532b52cf7c
The fist line contains one integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2 \cdot T$$$ lines contain independent queries — one query per two lines. The first line contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$1 \le a \le 10^8$$$, $$$1 \le b \le 10^8$$$) ...
1,500
Print $$$T$$$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.
standard output
PASSED
c27da84757fcf56642069bff330eb50b
train_002.jsonl
1566484500
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as...
256 megabytes
import java.util.*; import java.io.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next...
Java
["4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00"]
2 seconds
["94\n25\n2900000000\n13"]
NoteThe optimal pipeline for the first query is shown at the picture above.The optimal pipeline for the second query is pictured below: The optimal (and the only possible) pipeline for the third query is shown below: The optimal pipeline for the fourth query is shown below:
Java 11
standard input
[ "dp", "greedy" ]
4fa609ef581f705df901f7532b52cf7c
The fist line contains one integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2 \cdot T$$$ lines contain independent queries — one query per two lines. The first line contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$1 \le a \le 10^8$$$, $$$1 \le b \le 10^8$$$) ...
1,500
Print $$$T$$$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.
standard output
PASSED
7b4291da18f99a4fa22b6fa95ea48042
train_002.jsonl
1305299400
There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class B83 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long k = in.nextLong(); int[] a = new int[n]; long allSum = 0; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); allSum += a[i];...
Java
["3 3\n1 2 1", "4 10\n3 3 2 1", "7 10\n1 3 3 1 2 3 1"]
2 seconds
["2", "-1", "6 2 3"]
NoteIn the first sample test: Before examination: {1, 2, 3} After the first examination: {2, 3} After the second examination: {3, 2} After the third examination: {2} In the second sample test: Before examination: {1, 2, 3, 4, 5, 6, 7} After the first examination: {2, 3, 4, 5, 6, 7} After the second examination: ...
Java 7
standard input
[ "binary search", "sortings", "math" ]
8126f40439f2ea808683d22115421c18
The first line of input data contains two space-separated integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 1014). In the second line are given space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109). Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you ca...
1,800
If the doctor will overall carry out less than k examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers — number of animals in the order in which they stand in the queue. Note that this sequence may be empty. This case is present in pretests. You can just print nothing or p...
standard output
PASSED
039cbcadc4ad0f71cfecc3831cfe55f7
train_002.jsonl
1305299400
There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.util.Comparator; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.io.Writer; import jav...
Java
["3 3\n1 2 1", "4 10\n3 3 2 1", "7 10\n1 3 3 1 2 3 1"]
2 seconds
["2", "-1", "6 2 3"]
NoteIn the first sample test: Before examination: {1, 2, 3} After the first examination: {2, 3} After the second examination: {3, 2} After the third examination: {2} In the second sample test: Before examination: {1, 2, 3, 4, 5, 6, 7} After the first examination: {2, 3, 4, 5, 6, 7} After the second examination: ...
Java 7
standard input
[ "binary search", "sortings", "math" ]
8126f40439f2ea808683d22115421c18
The first line of input data contains two space-separated integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 1014). In the second line are given space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109). Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you ca...
1,800
If the doctor will overall carry out less than k examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers — number of animals in the order in which they stand in the queue. Note that this sequence may be empty. This case is present in pretests. You can just print nothing or p...
standard output
PASSED
f09fb00505a4fba7607310d5a6a3e04c
train_002.jsonl
1305299400
There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his...
256 megabytes
import java.io.*; import java.util.*; public class B38 { public static void main(String[] args) throws FileNotFoundException { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); long k = in.nextLong(); int a[] = new int[n]; int max = -1000000000; l...
Java
["3 3\n1 2 1", "4 10\n3 3 2 1", "7 10\n1 3 3 1 2 3 1"]
2 seconds
["2", "-1", "6 2 3"]
NoteIn the first sample test: Before examination: {1, 2, 3} After the first examination: {2, 3} After the second examination: {3, 2} After the third examination: {2} In the second sample test: Before examination: {1, 2, 3, 4, 5, 6, 7} After the first examination: {2, 3, 4, 5, 6, 7} After the second examination: ...
Java 7
standard input
[ "binary search", "sortings", "math" ]
8126f40439f2ea808683d22115421c18
The first line of input data contains two space-separated integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 1014). In the second line are given space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109). Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you ca...
1,800
If the doctor will overall carry out less than k examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers — number of animals in the order in which they stand in the queue. Note that this sequence may be empty. This case is present in pretests. You can just print nothing or p...
standard output
PASSED
f1e48e5f7049bfb88803defa3b52f65e
train_002.jsonl
1305299400
There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Comparator; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import java.io.InputStream; ...
Java
["3 3\n1 2 1", "4 10\n3 3 2 1", "7 10\n1 3 3 1 2 3 1"]
2 seconds
["2", "-1", "6 2 3"]
NoteIn the first sample test: Before examination: {1, 2, 3} After the first examination: {2, 3} After the second examination: {3, 2} After the third examination: {2} In the second sample test: Before examination: {1, 2, 3, 4, 5, 6, 7} After the first examination: {2, 3, 4, 5, 6, 7} After the second examination: ...
Java 7
standard input
[ "binary search", "sortings", "math" ]
8126f40439f2ea808683d22115421c18
The first line of input data contains two space-separated integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 1014). In the second line are given space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109). Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you ca...
1,800
If the doctor will overall carry out less than k examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers — number of animals in the order in which they stand in the queue. Note that this sequence may be empty. This case is present in pretests. You can just print nothing or p...
standard output
PASSED
ac252f3bc0d3135cce2c0abaaaad8563
train_002.jsonl
1305299400
There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his...
256 megabytes
import java.io.*; import java.util.*; public class Pr83B { public static void main(String[] args) throws IOException { new Pr83B().run(); } BufferedReader in; PrintWriter out; StringTokenizer st; String nextToken() throws IOException { while (st == null || !st.hasMoreTokens()) { st = new StringTokenizer...
Java
["3 3\n1 2 1", "4 10\n3 3 2 1", "7 10\n1 3 3 1 2 3 1"]
2 seconds
["2", "-1", "6 2 3"]
NoteIn the first sample test: Before examination: {1, 2, 3} After the first examination: {2, 3} After the second examination: {3, 2} After the third examination: {2} In the second sample test: Before examination: {1, 2, 3, 4, 5, 6, 7} After the first examination: {2, 3, 4, 5, 6, 7} After the second examination: ...
Java 7
standard input
[ "binary search", "sortings", "math" ]
8126f40439f2ea808683d22115421c18
The first line of input data contains two space-separated integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 1014). In the second line are given space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109). Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you ca...
1,800
If the doctor will overall carry out less than k examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers — number of animals in the order in which they stand in the queue. Note that this sequence may be empty. This case is present in pretests. You can just print nothing or p...
standard output
PASSED
9296c835705a29f60a4a3b2d350956c6
train_002.jsonl
1305299400
There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his...
256 megabytes
import java.io.*; import java.util.*; public class B83 { BufferedReader br; StringTokenizer in; PrintWriter out; int n, max; long k; int[] a; public String nextToken() throws IOException { while (in == null || !in.hasMoreTokens()) { in = new StringTokenizer(br.readLine(...
Java
["3 3\n1 2 1", "4 10\n3 3 2 1", "7 10\n1 3 3 1 2 3 1"]
2 seconds
["2", "-1", "6 2 3"]
NoteIn the first sample test: Before examination: {1, 2, 3} After the first examination: {2, 3} After the second examination: {3, 2} After the third examination: {2} In the second sample test: Before examination: {1, 2, 3, 4, 5, 6, 7} After the first examination: {2, 3, 4, 5, 6, 7} After the second examination: ...
Java 7
standard input
[ "binary search", "sortings", "math" ]
8126f40439f2ea808683d22115421c18
The first line of input data contains two space-separated integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 1014). In the second line are given space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109). Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you ca...
1,800
If the doctor will overall carry out less than k examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers — number of animals in the order in which they stand in the queue. Note that this sequence may be empty. This case is present in pretests. You can just print nothing or p...
standard output
PASSED
53d5197e08e96af8259376d0d0cab360
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.Scanner; public class Solution { public static void main(String args[]) { Scanner s=new Scanner(System.in); int p=s.nextInt(); int q=s.nextInt(); int l=s.nextInt(); int r=s.nextInt(); int[][] zTimes=new int[p][2]; for(int i=0;i<p;i++) ...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
d62b3dd6e4d47541b87d8971749d83f0
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.StringTokenizer; public class ChatOnline { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
210a1dd2d3eff785542cf273ba277d38
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
/** * Created by Omar on 1/30/2016. */ import java.util.*; import java.io.*; public class Chat { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] parts=br.readLine().split(" "); int p=Integer.pars...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
5550363f9929fe80d7ef64489584d649
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.Scanner; import java.util.List; import java.util.ArrayList; import java.util.Set; import java.util.HashSet; public class B469 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int p = sc.nextInt(); int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
b5018120ecb7ad8aa72b3117d573056c
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; import java.math.*; public class j8 implements Runnable { public void run(){ InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); int p=in.nextInt(); int q=in.nextInt(); int l=in.nextInt(); int r=in.nex...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
e046ae508a0e340f3122836eaa1b9787
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.*; import java.io.*; public class Main { static StreamTokenizer st; static int[] zb, ze, xb, xe; public static void main(String[] args) throws IOException { st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); int p = ri(); int q = ri(); int l = ri(); int r = ...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
b1bef1c64ea9aba5d60249563cd2ffbc
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.*; import java.io.*; public class B { Reader in; PrintWriter out; int i = 0, j = 0; void solve() { //START// int p = in.nextInt(), q = in.nextInt(), l = in.nextInt(), r = in.nextInt(); BitSet covered = new BitSet(1001); int[] a = new int[p...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
98c2cf565169d91fad18a69d32634a9c
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.Scanner; public class chatOnline { static int update[] = new int[1001]; public static void main(String args[]) { Scanner sc = new Scanner(System.in); int p = sc.nextInt(); int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int[]...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
26380ebd41501891ee142fff7c48c38f
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.InputMismatchException; public class Main1 { public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); int p = sc.nextInt(); int q = sc.nextInt()...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
11fc57eea3e8119a7d37df13bcefc377
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.io.*; import java.util.*; public class A25{ static class Pair{ int left; int right; } public static boolean intersect(Pair p1,Pair p2,int t){ if(p2.left+t <= p1.right && p2.left+t >=p1.left) return true; else if(p2.right+t <=p1.right && p2.right+...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
864c1c254de9c8a94c207e343a88c945
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.Scanner; public class ChatOnline { public static void main(String[] args) { Scanner input = new Scanner(System.in); int p=input.nextInt(), q=input.nextInt(), l=input.nextInt(), r=input.nextInt(); int[] xs = new int[p], ys=new int[p]; boolean[] v = new boolean[1004]; int t = 0; for(int i...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
07c21ddd7f7de835f3ad523379f49b14
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.*; public class CodeForces implements Runnable { private Scanner scanner; public static void main(String args[]) { new Thread(new CodeForces()).start(); } public void run() { scanner = new Scanner(System.in); solution(); scanner.close(); } //651B, 469A, 469B public void soluti...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
906683cf4774c6fa77c964a66cae3dfb
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.*; public class Main{ public static void main(String args[]){ int i,j,c=0,k,a1,a2; Scanner sc=new Scanner(System.in); int p=sc.nextInt(); int q=sc.nextInt(); int l=sc.nextInt(); int r=sc.nextInt(); int a[][]=new int [p][2]; int b[][]=n...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
4992ee26fd9365ecef756f78c11bfab8
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import javax.print.attribute.standard.PrinterIsAcceptingJobs; import java.io.*; import java.math.BigInteger; import java.sql.Array; import java.util.*; public class TaskC { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWr...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
d631f7ef4d6fa2e46958648f4b76ccb3
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
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. */ //import com.sun.xml.internal.ws.util.StringUtils; import java.io.BufferedReader; import java.io.IOException; import java.io.Inp...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output