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
222f7220092784ebb5f5f2f3ad07b006
train_001.jsonl
1583246100
To become the king of Codeforces, Kuroni has to solve the following problem.He is given $$$n$$$ numbers $$$a_1, a_2, \dots, a_n$$$. Help Kuroni to calculate $$$\prod_{1\le i<j\le n} |a_i - a_j|$$$. As result can be very big, output it modulo $$$m$$$.If you are not familiar with short notation, $$$\prod_{1\le i<j\...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputReader in = new InputReader(); int N = in.nextInt(); int M = in.nextInt(); if (N > M) { System.out.println(0); return; } int[] A = new int[N]; for (int i = 0; i < N; i++) { A[i] = in.nextInt...
Java
["2 10\n8 5", "3 12\n1 4 5", "3 7\n1 4 9"]
1 second
["3", "0", "1"]
NoteIn the first sample, $$$|8 - 5| = 3 \equiv 3 \bmod 10$$$.In the second sample, $$$|1 - 4|\cdot|1 - 5|\cdot|4 - 5| = 3\cdot 4 \cdot 1 = 12 \equiv 0 \bmod 12$$$.In the third sample, $$$|1 - 4|\cdot|1 - 9|\cdot|4 - 9| = 3 \cdot 8 \cdot 5 = 120 \equiv 1 \bmod 7$$$.
Java 8
standard input
[ "combinatorics", "number theory", "brute force", "math" ]
bf115b24d85a0581e709c012793b248b
The first line contains two integers $$$n$$$, $$$m$$$ ($$$2\le n \le 2\cdot 10^5$$$, $$$1\le m \le 1000$$$) — number of numbers and modulo. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
1,600
Output the single number — $$$\prod_{1\le i&lt;j\le n} |a_i - a_j| \bmod m$$$.
standard output
PASSED
231ba9d68fb96994c79829402a7a1870
train_001.jsonl
1583246100
To become the king of Codeforces, Kuroni has to solve the following problem.He is given $$$n$$$ numbers $$$a_1, a_2, \dots, a_n$$$. Help Kuroni to calculate $$$\prod_{1\le i&lt;j\le n} |a_i - a_j|$$$. As result can be very big, output it modulo $$$m$$$.If you are not familiar with short notation, $$$\prod_{1\le i&lt;j\...
256 megabytes
import java.util.*; public class Main { static Scanner input = new Scanner(System.in); public static void main(String[] args) { int n = input.nextInt(); int mod = input.nextInt(); int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = input.nextInt(); } ...
Java
["2 10\n8 5", "3 12\n1 4 5", "3 7\n1 4 9"]
1 second
["3", "0", "1"]
NoteIn the first sample, $$$|8 - 5| = 3 \equiv 3 \bmod 10$$$.In the second sample, $$$|1 - 4|\cdot|1 - 5|\cdot|4 - 5| = 3\cdot 4 \cdot 1 = 12 \equiv 0 \bmod 12$$$.In the third sample, $$$|1 - 4|\cdot|1 - 9|\cdot|4 - 9| = 3 \cdot 8 \cdot 5 = 120 \equiv 1 \bmod 7$$$.
Java 8
standard input
[ "combinatorics", "number theory", "brute force", "math" ]
bf115b24d85a0581e709c012793b248b
The first line contains two integers $$$n$$$, $$$m$$$ ($$$2\le n \le 2\cdot 10^5$$$, $$$1\le m \le 1000$$$) — number of numbers and modulo. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
1,600
Output the single number — $$$\prod_{1\le i&lt;j\le n} |a_i - a_j| \bmod m$$$.
standard output
PASSED
ac7cd3248e27ebe2f8174c7198e091c5
train_001.jsonl
1583246100
To become the king of Codeforces, Kuroni has to solve the following problem.He is given $$$n$$$ numbers $$$a_1, a_2, \dots, a_n$$$. Help Kuroni to calculate $$$\prod_{1\le i&lt;j\le n} |a_i - a_j|$$$. As result can be very big, output it modulo $$$m$$$.If you are not familiar with short notation, $$$\prod_{1\le i&lt;j\...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String[] args) throws java.lang.Exception { Reader pm =new Reader(); //Scanner pm = new Scanner(new BufferedReader(new InputStreamReader(System.in))); int n = pm.nextInt(); ...
Java
["2 10\n8 5", "3 12\n1 4 5", "3 7\n1 4 9"]
1 second
["3", "0", "1"]
NoteIn the first sample, $$$|8 - 5| = 3 \equiv 3 \bmod 10$$$.In the second sample, $$$|1 - 4|\cdot|1 - 5|\cdot|4 - 5| = 3\cdot 4 \cdot 1 = 12 \equiv 0 \bmod 12$$$.In the third sample, $$$|1 - 4|\cdot|1 - 9|\cdot|4 - 9| = 3 \cdot 8 \cdot 5 = 120 \equiv 1 \bmod 7$$$.
Java 8
standard input
[ "combinatorics", "number theory", "brute force", "math" ]
bf115b24d85a0581e709c012793b248b
The first line contains two integers $$$n$$$, $$$m$$$ ($$$2\le n \le 2\cdot 10^5$$$, $$$1\le m \le 1000$$$) — number of numbers and modulo. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
1,600
Output the single number — $$$\prod_{1\le i&lt;j\le n} |a_i - a_j| \bmod m$$$.
standard output
PASSED
58435479480f10bb6a362f2d9630f7ef
train_001.jsonl
1583246100
To become the king of Codeforces, Kuroni has to solve the following problem.He is given $$$n$$$ numbers $$$a_1, a_2, \dots, a_n$$$. Help Kuroni to calculate $$$\prod_{1\le i&lt;j\le n} |a_i - a_j|$$$. As result can be very big, output it modulo $$$m$$$.If you are not familiar with short notation, $$$\prod_{1\le i&lt;j\...
256 megabytes
import java.lang.*; import java.util.*; import java.io.*; public class Main { void solve(){ int n=ni(),m=ni(); if(n>m){ pw.println("0"); return; } long a[]=new long[n]; for(int i=0;i<n;i++) a[i]=nl(); Arrays.sort(a); long ans=1; for(int...
Java
["2 10\n8 5", "3 12\n1 4 5", "3 7\n1 4 9"]
1 second
["3", "0", "1"]
NoteIn the first sample, $$$|8 - 5| = 3 \equiv 3 \bmod 10$$$.In the second sample, $$$|1 - 4|\cdot|1 - 5|\cdot|4 - 5| = 3\cdot 4 \cdot 1 = 12 \equiv 0 \bmod 12$$$.In the third sample, $$$|1 - 4|\cdot|1 - 9|\cdot|4 - 9| = 3 \cdot 8 \cdot 5 = 120 \equiv 1 \bmod 7$$$.
Java 8
standard input
[ "combinatorics", "number theory", "brute force", "math" ]
bf115b24d85a0581e709c012793b248b
The first line contains two integers $$$n$$$, $$$m$$$ ($$$2\le n \le 2\cdot 10^5$$$, $$$1\le m \le 1000$$$) — number of numbers and modulo. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
1,600
Output the single number — $$$\prod_{1\le i&lt;j\le n} |a_i - a_j| \bmod m$$$.
standard output
PASSED
4ffe78711a171c6941c7d84bb122838e
train_001.jsonl
1583246100
To become the king of Codeforces, Kuroni has to solve the following problem.He is given $$$n$$$ numbers $$$a_1, a_2, \dots, a_n$$$. Help Kuroni to calculate $$$\prod_{1\le i&lt;j\le n} |a_i - a_j|$$$. As result can be very big, output it modulo $$$m$$$.If you are not familiar with short notation, $$$\prod_{1\le i&lt;j\...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { FastReader input=new FastReader(); PrintWriter out=new PrintWriter(System.out); int t=1; while(t-->0) { int n=input.nextInt(); int m=input.nextInt(); ...
Java
["2 10\n8 5", "3 12\n1 4 5", "3 7\n1 4 9"]
1 second
["3", "0", "1"]
NoteIn the first sample, $$$|8 - 5| = 3 \equiv 3 \bmod 10$$$.In the second sample, $$$|1 - 4|\cdot|1 - 5|\cdot|4 - 5| = 3\cdot 4 \cdot 1 = 12 \equiv 0 \bmod 12$$$.In the third sample, $$$|1 - 4|\cdot|1 - 9|\cdot|4 - 9| = 3 \cdot 8 \cdot 5 = 120 \equiv 1 \bmod 7$$$.
Java 8
standard input
[ "combinatorics", "number theory", "brute force", "math" ]
bf115b24d85a0581e709c012793b248b
The first line contains two integers $$$n$$$, $$$m$$$ ($$$2\le n \le 2\cdot 10^5$$$, $$$1\le m \le 1000$$$) — number of numbers and modulo. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$).
1,600
Output the single number — $$$\prod_{1\le i&lt;j\le n} |a_i - a_j| \bmod m$$$.
standard output
PASSED
d7cccf0dd22cbed71c0c6a4db26708ca
train_001.jsonl
1557671700
Let $$$s$$$ be some string consisting of symbols "0" or "1". Let's call a string $$$t$$$ a substring of string $$$s$$$, if there exists such number $$$1 \leq l \leq |s| - |t| + 1$$$ that $$$t = s_l s_{l+1} \ldots s_{l + |t| - 1}$$$. Let's call a substring $$$t$$$ of string $$$s$$$ unique, if there exist only one such $...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static void main() throws Exception{ int n=sc.nextInt(),k=sc.nextInt(); int a=(n-k)/2; int c=0; while(c<n) { for(int i=0;i<a && c<n;i++,c++) { pw.print(0); } if(c==n)break; c++; pw.print(1); } } public static void main(String[]...
Java
["4 4", "5 3", "7 3"]
1 second
["1111", "01010", "1011011"]
NoteIn the first test, it's easy to see, that the only unique substring of string $$$s = $$$"1111" is all string $$$s$$$, which has length $$$4$$$.In the second test a string $$$s = $$$"01010" has minimal unique substring $$$t =$$$"101", which has length $$$3$$$.In the third test a string $$$s = $$$"1011011" has minima...
Java 11
standard input
[ "constructive algorithms", "math", "strings" ]
7e8baa4fb780f11e66bb2b7078e34c04
The first line contains two integers $$$n$$$ and $$$k$$$, separated by spaces ($$$1 \leq k \leq n \leq 100\,000$$$, $$$(k \bmod 2) = (n \bmod 2)$$$).
2,200
Print a string $$$s$$$ of length $$$n$$$, consisting of symbols "0" and "1". Minimal length of the unique substring of $$$s$$$ should be equal to $$$k$$$. You can find any suitable string. It is guaranteed, that there exists at least one such string.
standard output
PASSED
81c417794dbcbd291a1b3d89be43a55b
train_001.jsonl
1517582100
Recently n students from city S moved to city P to attend a programming camp.They moved there by train. In the evening, all students in the train decided that they want to drink some tea. Of course, no two people can use the same teapot simultaneously, so the students had to form a queue to get their tea.i-th student c...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static...
Java
["2\n2\n1 3\n1 4\n3\n1 5\n1 1\n2 3"]
1 second
["1 2 \n1 0 2"]
NoteThe example contains 2 tests: During 1-st second, students 1 and 2 come to the queue, and student 1 gets his tea. Student 2 gets his tea during 2-nd second. During 1-st second, students 1 and 2 come to the queue, student 1 gets his tea, and student 2 leaves without tea. During 2-nd second, student 3 comes and get...
Java 8
standard input
[ "implementation" ]
471f80e349e70339eedd20d45b16e253
The first line contains one integer t — the number of test cases to solve (1 ≤ t ≤ 1000). Then t test cases follow. The first line of each test case contains one integer n (1 ≤ n ≤ 1000) — the number of students. Then n lines follow. Each line contains two integer li, ri (1 ≤ li ≤ ri ≤ 5000) — the second i-th student c...
1,200
For each test case print n integers. i-th of them must be equal to the second when i-th student gets his tea, or 0 if he leaves without tea.
standard output
PASSED
234c76fe4f38e031b93b7d2b336acb60
train_001.jsonl
1517582100
Recently n students from city S moved to city P to attend a programming camp.They moved there by train. In the evening, all students in the train decided that they want to drink some tea. Of course, no two people can use the same teapot simultaneously, so the students had to form a queue to get their tea.i-th student c...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.StringTokenizer; public class B{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int c = Integer.parseInt(in.readLine()...
Java
["2\n2\n1 3\n1 4\n3\n1 5\n1 1\n2 3"]
1 second
["1 2 \n1 0 2"]
NoteThe example contains 2 tests: During 1-st second, students 1 and 2 come to the queue, and student 1 gets his tea. Student 2 gets his tea during 2-nd second. During 1-st second, students 1 and 2 come to the queue, student 1 gets his tea, and student 2 leaves without tea. During 2-nd second, student 3 comes and get...
Java 8
standard input
[ "implementation" ]
471f80e349e70339eedd20d45b16e253
The first line contains one integer t — the number of test cases to solve (1 ≤ t ≤ 1000). Then t test cases follow. The first line of each test case contains one integer n (1 ≤ n ≤ 1000) — the number of students. Then n lines follow. Each line contains two integer li, ri (1 ≤ li ≤ ri ≤ 5000) — the second i-th student c...
1,200
For each test case print n integers. i-th of them must be equal to the second when i-th student gets his tea, or 0 if he leaves without tea.
standard output
PASSED
9b070b5d0f72ca921a7de20c0baa6325
train_001.jsonl
1517582100
Recently n students from city S moved to city P to attend a programming camp.They moved there by train. In the evening, all students in the train decided that they want to drink some tea. Of course, no two people can use the same teapot simultaneously, so the students had to form a queue to get their tea.i-th student c...
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.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.Writer; import java.io.OutputStreamW...
Java
["2\n2\n1 3\n1 4\n3\n1 5\n1 1\n2 3"]
1 second
["1 2 \n1 0 2"]
NoteThe example contains 2 tests: During 1-st second, students 1 and 2 come to the queue, and student 1 gets his tea. Student 2 gets his tea during 2-nd second. During 1-st second, students 1 and 2 come to the queue, student 1 gets his tea, and student 2 leaves without tea. During 2-nd second, student 3 comes and get...
Java 8
standard input
[ "implementation" ]
471f80e349e70339eedd20d45b16e253
The first line contains one integer t — the number of test cases to solve (1 ≤ t ≤ 1000). Then t test cases follow. The first line of each test case contains one integer n (1 ≤ n ≤ 1000) — the number of students. Then n lines follow. Each line contains two integer li, ri (1 ≤ li ≤ ri ≤ 5000) — the second i-th student c...
1,200
For each test case print n integers. i-th of them must be equal to the second when i-th student gets his tea, or 0 if he leaves without tea.
standard output
PASSED
ffd14e867bab7a467c7faac8377d6aeb
train_001.jsonl
1517582100
Recently n students from city S moved to city P to attend a programming camp.They moved there by train. In the evening, all students in the train decided that they want to drink some tea. Of course, no two people can use the same teapot simultaneously, so the students had to form a queue to get their tea.i-th student c...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class B{ static int t,n,l[],r[],res[]; static void MainMethod()throws Exception{ t=reader.nextInt(); int i,k=0; for (t=t;t>0;t--) { n=reader.nextInt(); l=new int[n];r=new int[n]; res=new int [n]; for (i=0;i<n;i++) { l[i]=reader....
Java
["2\n2\n1 3\n1 4\n3\n1 5\n1 1\n2 3"]
1 second
["1 2 \n1 0 2"]
NoteThe example contains 2 tests: During 1-st second, students 1 and 2 come to the queue, and student 1 gets his tea. Student 2 gets his tea during 2-nd second. During 1-st second, students 1 and 2 come to the queue, student 1 gets his tea, and student 2 leaves without tea. During 2-nd second, student 3 comes and get...
Java 8
standard input
[ "implementation" ]
471f80e349e70339eedd20d45b16e253
The first line contains one integer t — the number of test cases to solve (1 ≤ t ≤ 1000). Then t test cases follow. The first line of each test case contains one integer n (1 ≤ n ≤ 1000) — the number of students. Then n lines follow. Each line contains two integer li, ri (1 ≤ li ≤ ri ≤ 5000) — the second i-th student c...
1,200
For each test case print n integers. i-th of them must be equal to the second when i-th student gets his tea, or 0 if he leaves without tea.
standard output
PASSED
dd6a08ac1b5bd44b04f1927095104d11
train_001.jsonl
1517582100
Recently n students from city S moved to city P to attend a programming camp.They moved there by train. In the evening, all students in the train decided that they want to drink some tea. Of course, no two people can use the same teapot simultaneously, so the students had to form a queue to get their tea.i-th student c...
256 megabytes
import java.lang.*; import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class Main { public void solve() throws IOException { int t = nextInt(); for (int tt = 0; tt < t; tt++) { int n = nextInt(); int a[] = new int[n], b...
Java
["2\n2\n1 3\n1 4\n3\n1 5\n1 1\n2 3"]
1 second
["1 2 \n1 0 2"]
NoteThe example contains 2 tests: During 1-st second, students 1 and 2 come to the queue, and student 1 gets his tea. Student 2 gets his tea during 2-nd second. During 1-st second, students 1 and 2 come to the queue, student 1 gets his tea, and student 2 leaves without tea. During 2-nd second, student 3 comes and get...
Java 8
standard input
[ "implementation" ]
471f80e349e70339eedd20d45b16e253
The first line contains one integer t — the number of test cases to solve (1 ≤ t ≤ 1000). Then t test cases follow. The first line of each test case contains one integer n (1 ≤ n ≤ 1000) — the number of students. Then n lines follow. Each line contains two integer li, ri (1 ≤ li ≤ ri ≤ 5000) — the second i-th student c...
1,200
For each test case print n integers. i-th of them must be equal to the second when i-th student gets his tea, or 0 if he leaves without tea.
standard output
PASSED
ac37d0845d17dbf9c687d5b65b78f23b
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.util.*; public class CodeForces { static int MAX = 100001; static int[] prime = new int[MAX + 1]; static int[] countdiv = new int[MAX + 1]; static void SieveOfEratosthenes() { for (int i = 2; i * i <= MAX; ++i) { if (prime[i] == 0) for (int j = i * 2; j <= M...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
492c8079a56cb5f3264f211ad01d8f20
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.util.*; import java.io.*; public class Main757B { static PrintWriter out=new PrintWriter(System.out); public static void main(String[] args) throws IOException { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=new int[100001]; Arrays.fill(a,0); for(int i=0;i<n;i+...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
1ce64b5e613d4073f1853f1f7ce44f8f
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.StringTokenizer; public class B391 { public static void main(String[] args) { boolean[] prime = new boolean[400]; for(int i=2;i<prime.length;i++){...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
cb868b49159a8ef7db9704e6080ace90
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; public class CF757B { public static void main(String args[]){ InputReader in = new InputReader(System.in); //Ou...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
4880c81752f740ed72fa76d2dec1ba14
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import static java.lang.System.out; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] s = new int[n]; int m = 0; for (int i=0;i<n;i++) { s[i] = sc.nextInt(); m = Math.max(m,...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
7e9ceedd601cd3521cc5d5fc55d86555
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.util.*; import java.io.*; /** * * @author root */ public class B { public static void main(String args[]){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int a[] = new int[n]; for(int i = 0;i<n;i++) a[i] = in.nextInt(); int counts[] = new int[10000...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
2f733b41d3955139b7836a6ac58260f8
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.util.*; import java.io.*; /** * * @author root */ public class B { public static void main(String args[]){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int a[] = new int[n]; for(int i = 0;i<n;i++) a[i] = in.nextInt(); int counts[] = new int[10000...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
1c2b197f28d8d0e2714d7dcdee6dc389
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeMap; import java.io.IOException; import java.io.Buffe...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
3bb8aa0cd9e0937aeff240703b6c6bcb
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
/* * UMANG PANCHAL * DAIICT */ import java.util.*; import java.io.*; import java.math.*; import java.util.Comparator; public class Main { private static final Comparator<? super Integer> Comparator = null; static LinkedList<Integer> adj[]; static ArrayList<Integer> adj1[]; static int[] color,visited1; stati...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
7426d1e9625b78ac9c404f76d9266e09
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class Tester { public static long mod=(long)(1e9+7); public static long x,y,d; public static void main(String[] args) { InputReader s=new InputReader(System.in); OutputStream outputStream = System.out; PrintWriter out=ne...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
14b8f07c44f782dffdf1d848db890ba3
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class Tester { public static long mod=(long)(1e9+7); public static long x,y,d; public static void main(String[] args) { InputReader s=new InputReader(System.in); OutputStream outputStream = System.out; PrintWriter out=ne...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
05f55dd700a8b3b728571c232d5056ec
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.util.*; public class Test2 { private static boolean isEven(int num) { return num % 2 == 0; } private static HashMap<Integer, Integer> primeFactors(int num) { HashMap<Integer, Integer> hm = new HashMap<>(); while (isEven(num)) { if (hm.containsKey(2)) ...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
35733ba29eb96e098bbc15c16ccc27c7
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; import java.util.Set; /** * Created by Vasyukevich Andrey on 12.01.2017. */ public class B { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int[] cnt = new int[100100]; int n...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
17d6b6de1e0a3bbd76b7aeece4f831a3
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; import java.util.Set; /** * Created by Vasyukevich Andrey on 12.01.2017. */ public class B { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int[] cnt = new int[100100]; int n...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
fc089b2f319f4186b34192389af9855b
train_001.jsonl
1484235300
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k &gt; 1 Pokemon with strengths {s1, s2,...
512 megabytes
import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; import java.util.Set; /** * Created by Vasyukevich Andrey on 12.01.2017. */ public class B { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int[] cnt = new int[100100]; int n...
Java
["3\n2 3 4", "5\n2 3 4 6 7"]
2 seconds
["2", "3"]
Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there ...
Java 8
standard input
[ "number theory", "greedy", "math" ]
eea7860e6bbbe5f399b9123ebd663e3e
The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.
1,400
Print single integer — the maximum number of Pokemons Bash can take.
standard output
PASSED
f93c1c3960c0ff21592de2c9e2dafedf
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.io.IOException; import java.util.ArrayList; import java.io.UncheckedIOException; import java.util.List; import java.io.Closeable; import java.io.Writer; import java.io.O...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
4b5bfc4d5f27c1061b78a799ff6d9211
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.io.IOException; import java.util.ArrayList; import java.io.UncheckedIOException; import java.util.List; import java.io.Closeable; import java.io.Writer; import java.io.O...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
a834f727aee33753d288e87cb0396cde
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
51844715d59e33bfd55f9af04eb80e96
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; public class E1325 { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); int[] in = sc.nextIntArr(n); int[] arr = new int[(int) 1e6 + 1...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
a0365cca3457af8088c61a1f1b9ab290
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; public class E1325 { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); int[] in = sc.nextIntArr(n); int[] arr = new int[(int) 1e6 + 1...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
99b91169e60de6499848570a68a5429c
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
import java.util.*; import java.io.*; public class E { public static void main(String[] args) { FastScanner sc = new FastScanner(); int n = sc.nextInt(); HashSet<Integer> set = new HashSet<>(); boolean two = false; for(int i = 0; i < n; i++) { int a = reduce(sc.nextInt()); if(a == 1) { System.out....
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
9c64e6ad2441b2965c7ca825addbe98a
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; public class E1325 { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); int[] in = sc.nextIntArr(n); int[] arr = new int[(int) 1e6 + 1...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
c112a09f0755e699b122b29d2849c53d
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
import java.io.*; import java.util.*; public class GFG { private static int MAX=1000000000; private static int factor(int a){ int n=1,cnt=0; while(a%2==0){ a/=2; cnt++; } if(cnt%2!=0) n=2; for(int i=3;i*i<=a;i+=2){ cnt=0; while(a%i==0){ a/=i; cnt++; } if(cnt%2!=0) n*=i;...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
89c7c0fdd34b56a953b81dd6a5adecb2
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class E { private static int pf[]; private static final int lim=(int)(1e6+5); private static ArrayList<Integer> edge[]; private static int dist[], parent[]; private static ArrayList<Integer> vis; private static void sieve() ...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
7e521c1f401839d16d12e2f2f7ed84dd
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class E { private static final int lim=(int)(1e6+5); private static int[] dist, parent, spf; private static ArrayList<Integer> edge[], vis; private static void sieve() { for(int i=2;i<lim;i++) { if(spf[...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
47934459dc2203e6382f6f093ec4e591
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class E { private static final int lim=(int)(1e6+5); private static int[] dist, parent, spf; private static ArrayList<Integer> edge[], vis; private static void sieve() { for(int i=2;i<lim;i++) { if(spf[...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
3a8d958efd046aaabb754b2fac8cdb99
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class E { private static int pf[]; private static final int lim=(int)(1e6+5); private static ArrayList<Integer> edge[]; private static int dist[], parent[]; private static ArrayList<Integer> vis; private static void sieve() ...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
acf169d386b2830b0ddc0e97707786fb
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class E { private static final int lim=(int)(1e6+5); private static int[] dist, parent, spf; private static ArrayList<Integer> edge[], vis; private static void sieve() { for(int i=2;i<lim;i++) { if(spf[...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
d2fe221687165c6482158c596e6e01ed
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
//package Round628; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; /** * @author sguar <shugangcao@gmail.com> * strive for greatness * Created on 2020-01-10 */ public class E { InputStream is; PrintWriter out; pri...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
8aafafbcace3c95756ae04e2cb536889
train_001.jsonl
1584196500
You are given an array $$$a$$$ of length $$$n$$$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.A sequence $$$a$$$ is a subsequence of an array $$$b$$$ if $$$a$$$ can be o...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.awt.Point; public class Main { static final long MOD = 998244353L; static final long INF = 1000000000000000007L; //static final long MOD = 1000000007L; //static final int INF = 1000000007; //static long[] factorial; public static void mai...
Java
["3\n1 4 6", "4\n2 3 6 6", "3\n6 15 10", "4\n2 3 5 7"]
3 seconds
["1", "2", "3", "-1"]
NoteIn the first sample, you can choose a subsequence $$$[1]$$$.In the second sample, you can choose a subsequence $$$[6, 6]$$$.In the third sample, you can choose a subsequence $$$[6, 15, 10]$$$.In the fourth sample, there is no such subsequence.
Java 8
standard input
[ "graphs", "number theory", "shortest paths", "dfs and similar", "brute force" ]
22a43ccaa9e5579dd193bc941855b47d
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^6$$$) — the elements of the array $$$a$$$.
2,600
Output the length of the shortest non-empty subsequence of $$$a$$$ product of whose elements is a perfect square. If there are several shortest subsequences, you can find any of them. If there's no such subsequence, print "-1".
standard output
PASSED
bf188bad82ff1d06e3d358c47677968f
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.util.*; import java.text.*; import java.io.*; import java.math.*; public class code5 { InputStream is; PrintWriter out; static long mod=pow(10,9)+7; static int dx[]={0,0,1,-1},dy[]={1,-1,0,0}; void solve() throws Exception { int n=ni(); int a[]=na(n); int max=1000000; int dp[]=new int[max...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
4401ab08f1f9d039d3b633f04ce0b37f
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; public class _566F { static final int MAX = 1111111; static int n; static int[] cnt = new int[MAX]; static int[] f = new int[MAX]; static List<Integer>[] factors = new Li...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
843e5ca7c3bbb108d3b39ed6b4c240a6
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main extends PrintWriter { BufferedReader in; StringTokenizer stok; final Random rand = new Random(31); final int inf = (int) 1e9; final long linf = (long) 1e18; final static String IO = "_std"; void solve...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
2ffec2131c24449d1ab91fc384c963df
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.util.*; import java.io.*; public class Solution { static int N = (int) 1e6 + 5; static int dp[] = new int[N]; static int a[] = new int[N]; public static void main(String[] ks) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.par...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
f35555ff95d8dc5f5d324fd33b6c2783
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.IOException; public class Main { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); ...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
78721887aabcdad6881f1fddfbb9f2bc
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; public class VK2015F { public static PrintWriter out; public static FastScanner in; private void solve() { int n = in.nextInt(); i...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
277daada099a17d67b01d8529a481d08
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; im...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
b0a493652c2da5da498ada722b0c854e
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; public class Main { static int[] inp; static int[] maxClique; public static void main(String[] args) throws Exception{ // write your code here BufferedReader reader = new BufferedReader(new InputStr...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
efe25797d956cd870c8ac92274f31f69
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.*; import java.util.*; public class Main{ public static class FastReader { BufferedReader br; StringTokenizer root; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (root == null || !root.hasMoreTokens()) { try { ro...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
152c63a37daaab6daca8eb03b2f67c9b
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExcept...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
57d5b7977acc6c4a2abc2175cea41104
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.*; import java.util.*; public class Main { static void solve(InputReader in, OutputWriter out) { int size = 1_000_000; int n = in.nextInt(); int max = 1; int[] ar = new int[size + 1]; for (int i = 0; i < n; i++) { int x = in.nextInt(); ...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
77ae6ab3e408b6a5374f795e711f64e7
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.util.*; import java.io.*; public class C { static final int N = (int)1e6; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine().trim()); int[] dp = new int[N+1]; boolean[] arr = new...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
a93a82f1d863a32087331acac7cb4c7f
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String []args)throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int array[] = new int[n]; boolean isPresent[] = new boolean[1000*1000 + 5]; StringToke...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
df78ab2bad699a454f4d87ac5a7b87aa
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.lang.*; import java.io.*; import java.util.*; import java.math.*; public class Main{ static int cnt[], dp[]; static BufferedReader br; static { br = new BufferedReader(new InputStreamReader(System.in)); cnt = new int[1048576]; dp = new int[1048576]; } static void solve() throws Exception { Ar...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
059ef5ff2dddb0142d0251346ce8fe17
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.uti...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
721cde23527248cd3bdca23afc037840
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { ...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
54a775655386bc18da2889beaf3f9778
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.*; import java.util.*; public class Template implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void init() throws FileNotFoundException { try { in = new BufferedReader(new FileReader("input.txt")); o...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
dfefe7d8984c5ae2e31e09d0ad3ddf6b
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
48f1f592a58ec3f0261a56f71221e371
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.StringTokenizer; import java.util.stream...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
7962af8c225de30e159b880c0059981f
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.InputMismatchException; import java.io.BufferedWriter; import java.io.PrintWriter; import java.io.Writer; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.IOExc...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
82b1bcaad9f597fa2ec64a71e6eb5982
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.*; import java.util.*; public class icpc { public static void main(String[] args) throws IOException { Reader in = new Reader(); //BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = in.nextInt(); int[] A = new int[n]; for (int...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
91ae8f1060b7c1818bb0d5eec4e40cf3
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.BitS...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
f5ede2d7feda0dbf18f9a89fb72c70c4
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static int n = 1+(int)1e6; static boolean[] has; static int memo[]; static int dp(int cur) { if(cur>=n || !has[cur])return -(int)1e8; if(m...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
708e2399f970278459bf3ac89eef3ef5
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
da20472e0612d048e5c1a6dbe117ecb1
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
/*Talent is something you make bloom , instinct is something you polish*/ import java.io.*; import java.math.*; import java.util.*; public class Main { static long mod=((long)1e9)+7;//toString public static int gcd(int a,int b){if(b==0)return a;else return gcd(b,a%b);} public static long pow_mod(long x,long...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
94209274acf4ff3e79fbf5e75d584300
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
//package vk2015.f; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class F { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(); int...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
5cfc927afb93112657c3a3ea031db821
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; //1 //5 10 //10 9 8 10 11 public class C { public static void main(String[] args)...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
b83d74bdd3227f1a6aa8e061e4aea13a
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class VkCup2015FinalsF { public static final int max = (int)1e6 + 10; public static void solve() { int n = s.nextInt(); int[] counts = new ...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
036c3e661eb78e6eb9f376c0e37e6ff0
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.*; import java.util.*; public class cliquediv { private static InputReader in; private static PrintWriter out; public static void main(String[] args) throws IOException { in = new InputReader(System.in); out = new PrintWriter(System.out, true); int n = in.nextInt(); int maxt = 100...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
3fee069486fd0c1f15894d5a4a1c2b57
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.awt.geom.Rectangle2D; import java.io.*; import java.math.BigInteger; import java.util.*; import sun.security.krb5.internal.crypto.dk.ArcFourCrypto; public class E { String line; StringTokenizer inputParser; BufferedReader is; FileInputStream fstream; DataInputStream in; void openInput(String file)...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
7244beb8dabf38c129b0246968bb7f32
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class p566f { public static int N; public static ArrayList<Integer> a = new ArrayList<Integer>(); public static int[] dp; public static int[] count = new int[1000010]; public static void main(String[] args) { InputStream inpu...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
15dcdfc4055f3c6338b6c2dea14b8257
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
/* Keep solving problems. */ import java.util.*; import java.io.*; public class CF566F { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; final long MOD = 1000L * 1000L * 1000L + 7; void solve() throws IOException { int n = nextInt(); int len = 1000010; ...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
0b066f774bf689eb7a2aa91fae209d05
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class WorkFile { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int n = In...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
5b8e29582628b9593bf4e5591b197ce5
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { static class Reader { private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} public int read() {if (nu...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
29a7d08889ec8b56ab5073528de042a0
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; public class CliqueInTheDivisibiltyGraph { static BufferedReader bf; static boolean nums[] = new boolean[1000001]; static int DP[] = new int[1000001]; int getMax(int curr) { if (curr >= nums.length) return 0; if (DP[c...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
e0a08cca9789222368789a6bc836862d
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
/*11:21 7:50*/ import java.util.*; import java.io.*; public class p14{ static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next()...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
fa500ae06f97b3d5d6af4bb81216d05e
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.util.*; import java.io.*; public class Abc { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() ...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
40af59d9b06892ddf09fb29897d45e84
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.util.*; import java.io.*; public class TaskF { private FastScanner in; private PrintWriter out; final int MAX = (int) 1e6 + 1; public void solve() throws IOException { int n = in.nextInt(); int[] res = new int[MAX]; Arrays.fill(res, 1); boolean[] have = new...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
b842078c8ce80ade5fd4da23c6e46e98
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.*; import java.util.*; import java.math.BigInteger; import java.util.Map.Entry; import static java.lang.Math.*; public class F extends PrintWriter { void run() { int n = nextInt(); int m = 1_000_001; int[] dp = new int[m]; int ans = 0; Arrays.fill(dp, 1); for (int i = 0; i < n; i++) { ...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
008ad3730504e786e92d994117234549
train_001.jsonl
1438273200
As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connecte...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["8\n3 4 6 8 10 18 21 24"]
1 second
["3"]
NoteIn the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.
Java 8
standard input
[ "dp", "number theory", "math" ]
f33991da3b4a57dd6535af86edeeddc0
The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A. The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.
1,500
Print a single number — the maximum size of a clique in a divisibility graph for set A.
standard output
PASSED
8d920071fb280ec1de6207e2c63c4b41
train_001.jsonl
1338737400
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≤ i ≤ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
256 megabytes
import java.io.*; import java.util.*; public class C implements Runnable { private MyScanner in; private PrintWriter out; private void solve() { int[][] h = new int[3][]; for (int i = 0; i < 3; ++i) { h[i] = new int[3 - i]; for (int j = 0; j < h[i].length; ++j) { ...
Java
["4 4 4\n4 4\n4"]
2 seconds
["6\naaaabb\naabbaa\nbbaaaa\nbbbbbb"]
null
Java 6
standard input
[ "constructive algorithms", "greedy", "math", "matrices" ]
d43786ca0472a5da735b04b9808c62d9
The first line contains space-separated integers h(s1, s2), h(s1, s3), h(s1, s4). The second line contains space-separated integers h(s2, s3) and h(s2, s4). The third line contains the single integer h(s3, s4). All given integers h(si, sj) are non-negative and do not exceed 105. It is guaranteed that at least one numbe...
2,400
Print -1 if there's no suitable set of strings. Otherwise print on the first line number len — the length of each string. On the i-th of the next four lines print string s'i. If there are multiple sets with the minimum length of the strings, print any of them.
standard output
PASSED
1eb2745593f60b281e7097ac329194a3
train_001.jsonl
1338737400
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≤ i ≤ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual so...
Java
["4 4 4\n4 4\n4"]
2 seconds
["6\naaaabb\naabbaa\nbbaaaa\nbbbbbb"]
null
Java 6
standard input
[ "constructive algorithms", "greedy", "math", "matrices" ]
d43786ca0472a5da735b04b9808c62d9
The first line contains space-separated integers h(s1, s2), h(s1, s3), h(s1, s4). The second line contains space-separated integers h(s2, s3) and h(s2, s4). The third line contains the single integer h(s3, s4). All given integers h(si, sj) are non-negative and do not exceed 105. It is guaranteed that at least one numbe...
2,400
Print -1 if there's no suitable set of strings. Otherwise print on the first line number len — the length of each string. On the i-th of the next four lines print string s'i. If there are multiple sets with the minimum length of the strings, print any of them.
standard output
PASSED
8cdb9afdfb759c4bbe5a4d35e689dd02
train_001.jsonl
1338737400
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≤ i ≤ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution ...
Java
["4 4 4\n4 4\n4"]
2 seconds
["6\naaaabb\naabbaa\nbbaaaa\nbbbbbb"]
null
Java 6
standard input
[ "constructive algorithms", "greedy", "math", "matrices" ]
d43786ca0472a5da735b04b9808c62d9
The first line contains space-separated integers h(s1, s2), h(s1, s3), h(s1, s4). The second line contains space-separated integers h(s2, s3) and h(s2, s4). The third line contains the single integer h(s3, s4). All given integers h(si, sj) are non-negative and do not exceed 105. It is guaranteed that at least one numbe...
2,400
Print -1 if there's no suitable set of strings. Otherwise print on the first line number len — the length of each string. On the i-th of the next four lines print string s'i. If there are multiple sets with the minimum length of the strings, print any of them.
standard output
PASSED
7e18b5f13a2bfb61920edf7893bae64b
train_001.jsonl
1338737400
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≤ i ≤ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
256 megabytes
//package round122; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; public class C { InputStream is; PrintWriter out; String INPUT = "10 10 8 8 8 10"; void solve() { int[] a = new int[6]; for(int i = 0;i < 6;i+...
Java
["4 4 4\n4 4\n4"]
2 seconds
["6\naaaabb\naabbaa\nbbaaaa\nbbbbbb"]
null
Java 6
standard input
[ "constructive algorithms", "greedy", "math", "matrices" ]
d43786ca0472a5da735b04b9808c62d9
The first line contains space-separated integers h(s1, s2), h(s1, s3), h(s1, s4). The second line contains space-separated integers h(s2, s3) and h(s2, s4). The third line contains the single integer h(s3, s4). All given integers h(si, sj) are non-negative and do not exceed 105. It is guaranteed that at least one numbe...
2,400
Print -1 if there's no suitable set of strings. Otherwise print on the first line number len — the length of each string. On the i-th of the next four lines print string s'i. If there are multiple sets with the minimum length of the strings, print any of them.
standard output
PASSED
038d20d594780d1a1fd6c06838a5fe5d
train_001.jsonl
1338737400
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≤ i ≤ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
256 megabytes
import java.awt.geom.*; import java.io.*; import java.math.*; import java.util.*; import java.util.regex.*; import static java.lang.Math.*; public class C { public static class M { // {{{ public static final boolean DETECT_OVERFLOW = false; public static long sub(long a, long b) { return add(a...
Java
["4 4 4\n4 4\n4"]
2 seconds
["6\naaaabb\naabbaa\nbbaaaa\nbbbbbb"]
null
Java 6
standard input
[ "constructive algorithms", "greedy", "math", "matrices" ]
d43786ca0472a5da735b04b9808c62d9
The first line contains space-separated integers h(s1, s2), h(s1, s3), h(s1, s4). The second line contains space-separated integers h(s2, s3) and h(s2, s4). The third line contains the single integer h(s3, s4). All given integers h(si, sj) are non-negative and do not exceed 105. It is guaranteed that at least one numbe...
2,400
Print -1 if there's no suitable set of strings. Otherwise print on the first line number len — the length of each string. On the i-th of the next four lines print string s'i. If there are multiple sets with the minimum length of the strings, print any of them.
standard output
PASSED
f65a73ecfb17788bfefb9391bd5951d7
train_001.jsonl
1338737400
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≤ i ≤ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
256 megabytes
import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; import java.util.*; import java.util.regex.*; import java.text.*; import java.math.*; import java.awt.geom.*; public class C { public static final boolean debug = false; void pln(Object o) {System.out.pr...
Java
["4 4 4\n4 4\n4"]
2 seconds
["6\naaaabb\naabbaa\nbbaaaa\nbbbbbb"]
null
Java 6
standard input
[ "constructive algorithms", "greedy", "math", "matrices" ]
d43786ca0472a5da735b04b9808c62d9
The first line contains space-separated integers h(s1, s2), h(s1, s3), h(s1, s4). The second line contains space-separated integers h(s2, s3) and h(s2, s4). The third line contains the single integer h(s3, s4). All given integers h(si, sj) are non-negative and do not exceed 105. It is guaranteed that at least one numbe...
2,400
Print -1 if there's no suitable set of strings. Otherwise print on the first line number len — the length of each string. On the i-th of the next four lines print string s'i. If there are multiple sets with the minimum length of the strings, print any of them.
standard output
PASSED
657f570bf8458521e5ef138e73deccdd
train_001.jsonl
1338737400
Hamming distance between strings a and b of equal length (denoted by h(a, b)) is equal to the number of distinct integers i (1 ≤ i ≤ |a|), such that ai ≠ bi, where ai is the i-th symbol of string a, bi is the i-th symbol of string b. For example, the Hamming distance between strings "aba" and "bba" equals 1, they have ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public cla...
Java
["4 4 4\n4 4\n4"]
2 seconds
["6\naaaabb\naabbaa\nbbaaaa\nbbbbbb"]
null
Java 6
standard input
[ "constructive algorithms", "greedy", "math", "matrices" ]
d43786ca0472a5da735b04b9808c62d9
The first line contains space-separated integers h(s1, s2), h(s1, s3), h(s1, s4). The second line contains space-separated integers h(s2, s3) and h(s2, s4). The third line contains the single integer h(s3, s4). All given integers h(si, sj) are non-negative and do not exceed 105. It is guaranteed that at least one numbe...
2,400
Print -1 if there's no suitable set of strings. Otherwise print on the first line number len — the length of each string. On the i-th of the next four lines print string s'i. If there are multiple sets with the minimum length of the strings, print any of them.
standard output
PASSED
2ac09be60b267d3004df75a93131bf71
train_001.jsonl
1470933300
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i is equal to xi coins.Vasiliy plans to buy his favorite drink for ...
256 megabytes
import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) throws FileNotFoundException { Scanner sc = new Scanner(System.in); ...
Java
["5\n3 10 8 6 11\n4\n1\n10\n3\n11"]
2 seconds
["0\n4\n1\n5"]
NoteOn the first day, Vasiliy won't be able to buy a drink in any of the shops.On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.On the third day, Vasiliy can buy a drink only in the shop number 1.Finally, on the last day Vasiliy can buy a drink in any shop.
Java 8
standard input
[ "dp", "binary search", "implementation" ]
80a03e6d513f4051175cd5cd1dea33b4
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of shops in the city that sell Vasiliy's favourite drink. The second line contains n integers xi (1 ≤ xi ≤ 100 000) — prices of the bottles of the drink in the i-th shop. The third line contains a single integer q (1 ≤ q ≤ 100 000) —...
1,100
Print q integers. The i-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the i-th day.
standard output
PASSED
4f914fd87931da1d99a8de3f53d83611
train_001.jsonl
1470933300
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i is equal to xi coins.Vasiliy plans to buy his favorite drink for ...
256 megabytes
import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) throws FileNotFoundException { Scanner sc = new Scanner(System.in); int ...
Java
["5\n3 10 8 6 11\n4\n1\n10\n3\n11"]
2 seconds
["0\n4\n1\n5"]
NoteOn the first day, Vasiliy won't be able to buy a drink in any of the shops.On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.On the third day, Vasiliy can buy a drink only in the shop number 1.Finally, on the last day Vasiliy can buy a drink in any shop.
Java 8
standard input
[ "dp", "binary search", "implementation" ]
80a03e6d513f4051175cd5cd1dea33b4
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of shops in the city that sell Vasiliy's favourite drink. The second line contains n integers xi (1 ≤ xi ≤ 100 000) — prices of the bottles of the drink in the i-th shop. The third line contains a single integer q (1 ≤ q ≤ 100 000) —...
1,100
Print q integers. The i-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the i-th day.
standard output
PASSED
33a7e202200fa0872b0ec2224997b00c
train_001.jsonl
1470933300
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i is equal to xi coins.Vasiliy plans to buy his favorite drink for ...
256 megabytes
import java .util.*; import java .io.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc =new Scanner(System.in); int n=sc.nextInt(); int []x=new int [100001]; for (int i=0;i<n;++i) x[sc.nextInt()]++; for (int i =1;i<100000;++i) x[i]=x[i-1]...
Java
["5\n3 10 8 6 11\n4\n1\n10\n3\n11"]
2 seconds
["0\n4\n1\n5"]
NoteOn the first day, Vasiliy won't be able to buy a drink in any of the shops.On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.On the third day, Vasiliy can buy a drink only in the shop number 1.Finally, on the last day Vasiliy can buy a drink in any shop.
Java 8
standard input
[ "dp", "binary search", "implementation" ]
80a03e6d513f4051175cd5cd1dea33b4
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of shops in the city that sell Vasiliy's favourite drink. The second line contains n integers xi (1 ≤ xi ≤ 100 000) — prices of the bottles of the drink in the i-th shop. The third line contains a single integer q (1 ≤ q ≤ 100 000) —...
1,100
Print q integers. The i-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the i-th day.
standard output
PASSED
da6b5279a3d7a5987b3b00f599059c1b
train_001.jsonl
1470933300
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i is equal to xi coins.Vasiliy plans to buy his favorite drink for ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Bb { public static void main(String[] args) throws IOException { Scanner sc=n...
Java
["5\n3 10 8 6 11\n4\n1\n10\n3\n11"]
2 seconds
["0\n4\n1\n5"]
NoteOn the first day, Vasiliy won't be able to buy a drink in any of the shops.On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.On the third day, Vasiliy can buy a drink only in the shop number 1.Finally, on the last day Vasiliy can buy a drink in any shop.
Java 8
standard input
[ "dp", "binary search", "implementation" ]
80a03e6d513f4051175cd5cd1dea33b4
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of shops in the city that sell Vasiliy's favourite drink. The second line contains n integers xi (1 ≤ xi ≤ 100 000) — prices of the bottles of the drink in the i-th shop. The third line contains a single integer q (1 ≤ q ≤ 100 000) —...
1,100
Print q integers. The i-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the i-th day.
standard output
PASSED
0c62b15723a3e1fb7f2ae56e00935454
train_001.jsonl
1470933300
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i is equal to xi coins.Vasiliy plans to buy his favorite drink for ...
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.InputMismatchException; import java.io.IOException; import java.util.StringTokenizer; import java.io.Writ...
Java
["5\n3 10 8 6 11\n4\n1\n10\n3\n11"]
2 seconds
["0\n4\n1\n5"]
NoteOn the first day, Vasiliy won't be able to buy a drink in any of the shops.On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.On the third day, Vasiliy can buy a drink only in the shop number 1.Finally, on the last day Vasiliy can buy a drink in any shop.
Java 8
standard input
[ "dp", "binary search", "implementation" ]
80a03e6d513f4051175cd5cd1dea33b4
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of shops in the city that sell Vasiliy's favourite drink. The second line contains n integers xi (1 ≤ xi ≤ 100 000) — prices of the bottles of the drink in the i-th shop. The third line contains a single integer q (1 ≤ q ≤ 100 000) —...
1,100
Print q integers. The i-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the i-th day.
standard output
PASSED
1a57e484162a96303b10224d36b50c1f
train_001.jsonl
1470933300
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i is equal to xi coins.Vasiliy plans to buy his favorite drink for ...
256 megabytes
import java.util.Scanner; import java.util.Arrays; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int[] search = new int[100000]; int n = input.nextInt(); int[] shops = new int[n]; for( int i=0; i<=n-1; i++) shops...
Java
["5\n3 10 8 6 11\n4\n1\n10\n3\n11"]
2 seconds
["0\n4\n1\n5"]
NoteOn the first day, Vasiliy won't be able to buy a drink in any of the shops.On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.On the third day, Vasiliy can buy a drink only in the shop number 1.Finally, on the last day Vasiliy can buy a drink in any shop.
Java 8
standard input
[ "dp", "binary search", "implementation" ]
80a03e6d513f4051175cd5cd1dea33b4
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of shops in the city that sell Vasiliy's favourite drink. The second line contains n integers xi (1 ≤ xi ≤ 100 000) — prices of the bottles of the drink in the i-th shop. The third line contains a single integer q (1 ≤ q ≤ 100 000) —...
1,100
Print q integers. The i-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the i-th day.
standard output
PASSED
f342b93c0a8b1ab8f679299b03ed06a9
train_001.jsonl
1470933300
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i is equal to xi coins.Vasiliy plans to buy his favorite drink for ...
256 megabytes
import java.util.Arrays; import java.util.Map; import java.util.Scanner; /** * Created by Kafukaaa on 16/9/25. */ public class InterestingDrink { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] x = new int[n]; for (int i = 0; i < n...
Java
["5\n3 10 8 6 11\n4\n1\n10\n3\n11"]
2 seconds
["0\n4\n1\n5"]
NoteOn the first day, Vasiliy won't be able to buy a drink in any of the shops.On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.On the third day, Vasiliy can buy a drink only in the shop number 1.Finally, on the last day Vasiliy can buy a drink in any shop.
Java 8
standard input
[ "dp", "binary search", "implementation" ]
80a03e6d513f4051175cd5cd1dea33b4
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of shops in the city that sell Vasiliy's favourite drink. The second line contains n integers xi (1 ≤ xi ≤ 100 000) — prices of the bottles of the drink in the i-th shop. The third line contains a single integer q (1 ≤ q ≤ 100 000) —...
1,100
Print q integers. The i-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the i-th day.
standard output
PASSED
e343aad40767895659d602c8c8e61872
train_001.jsonl
1470933300
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i is equal to xi coins.Vasiliy plans to buy his favorite drink for ...
256 megabytes
import java.util.*; public class Solution { public static void main(String args[]) { Scanner s = new Scanner(System.in); int numShops = s.nextInt(); int shops[] = new int[numShops]; for(int i = 0; i < numShops; i++) { shops[i] = s.nextInt(); } Arrays.sort(...
Java
["5\n3 10 8 6 11\n4\n1\n10\n3\n11"]
2 seconds
["0\n4\n1\n5"]
NoteOn the first day, Vasiliy won't be able to buy a drink in any of the shops.On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.On the third day, Vasiliy can buy a drink only in the shop number 1.Finally, on the last day Vasiliy can buy a drink in any shop.
Java 8
standard input
[ "dp", "binary search", "implementation" ]
80a03e6d513f4051175cd5cd1dea33b4
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of shops in the city that sell Vasiliy's favourite drink. The second line contains n integers xi (1 ≤ xi ≤ 100 000) — prices of the bottles of the drink in the i-th shop. The third line contains a single integer q (1 ≤ q ≤ 100 000) —...
1,100
Print q integers. The i-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the i-th day.
standard output
PASSED
185cfdd43877923964feb751a4d7759d
train_001.jsonl
1470933300
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i is equal to xi coins.Vasiliy plans to buy his favorite drink for ...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class hgfkuyf { public static int upperBound(int[] array, int value) { int low = 0; int length= array.length; int high = length; while (low < high) { final int mid = (low + high) / 2; if (value >= arra...
Java
["5\n3 10 8 6 11\n4\n1\n10\n3\n11"]
2 seconds
["0\n4\n1\n5"]
NoteOn the first day, Vasiliy won't be able to buy a drink in any of the shops.On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.On the third day, Vasiliy can buy a drink only in the shop number 1.Finally, on the last day Vasiliy can buy a drink in any shop.
Java 8
standard input
[ "dp", "binary search", "implementation" ]
80a03e6d513f4051175cd5cd1dea33b4
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of shops in the city that sell Vasiliy's favourite drink. The second line contains n integers xi (1 ≤ xi ≤ 100 000) — prices of the bottles of the drink in the i-th shop. The third line contains a single integer q (1 ≤ q ≤ 100 000) —...
1,100
Print q integers. The i-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the i-th day.
standard output
PASSED
ad2c9a92041a2db3572b0268cbabc13c
train_001.jsonl
1553267100
For a given set of two-dimensional points $$$S$$$, let's denote its extension $$$E(S)$$$ as the result of the following algorithm:Create another set of two-dimensional points $$$R$$$, which is initially equal to $$$S$$$. Then, while there exist four numbers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$ and $$$y_2$$$ such that $$$(x_...
1024 megabytes
import java.io.*; import java.util.*; public class F { public static void main(String[] args) throws IOException { try (Input input = new StandardInput(); PrintWriter writer = new PrintWriter(System.out)) { int n = input.nextInt(); final class Coordinate { private fi...
Java
["7\n1 1\n1 2\n2 1\n2 2\n1 2\n1 3\n2 1"]
3.5 seconds
["1 2 4 4 4 6 3"]
null
Java 8
standard input
[ "data structures", "dsu", "divide and conquer" ]
feff009596baf8e2d7f1aac36b2f077e
The first line contains one integer $$$q$$$ ($$$1 \le q \le 3 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ lines follow, each containing two integers $$$x_i$$$, $$$y_i$$$ ($$$1 \le x_i, y_i \le 3 \cdot 10^5$$$), denoting $$$i$$$-th query as follows: if $$$(x_i, y_i) \in S$$$, erase it from $$$S$$$, otherwise in...
2,600
Print $$$q$$$ integers. $$$i$$$-th integer should be equal to the size of $$$E(S)$$$ after processing first $$$i$$$ queries.
standard output
PASSED
595257a7532e602a075d1b6052afe126
train_001.jsonl
1553267100
For a given set of two-dimensional points $$$S$$$, let's denote its extension $$$E(S)$$$ as the result of the following algorithm:Create another set of two-dimensional points $$$R$$$, which is initially equal to $$$S$$$. Then, while there exist four numbers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$ and $$$y_2$$$ such that $$$(x_...
1024 megabytes
import java.util.*; import java.io.*; import java.text.*; //Solution Credits: Taranpreet Singh public class Main{ //SOLUTION BEGIN void pre() throws Exception{} TreeSet<Point>[] tr; int[] set; long[] szx, szy; void solve(int TC) throws Exception{ int n = ni(); int[][] p = new int...
Java
["7\n1 1\n1 2\n2 1\n2 2\n1 2\n1 3\n2 1"]
3.5 seconds
["1 2 4 4 4 6 3"]
null
Java 8
standard input
[ "data structures", "dsu", "divide and conquer" ]
feff009596baf8e2d7f1aac36b2f077e
The first line contains one integer $$$q$$$ ($$$1 \le q \le 3 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ lines follow, each containing two integers $$$x_i$$$, $$$y_i$$$ ($$$1 \le x_i, y_i \le 3 \cdot 10^5$$$), denoting $$$i$$$-th query as follows: if $$$(x_i, y_i) \in S$$$, erase it from $$$S$$$, otherwise in...
2,600
Print $$$q$$$ integers. $$$i$$$-th integer should be equal to the size of $$$E(S)$$$ after processing first $$$i$$$ queries.
standard output
PASSED
3c3f26357ab217c8133d78c13b43781f
train_001.jsonl
1553267100
For a given set of two-dimensional points $$$S$$$, let's denote its extension $$$E(S)$$$ as the result of the following algorithm:Create another set of two-dimensional points $$$R$$$, which is initially equal to $$$S$$$. Then, while there exist four numbers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$ and $$$y_2$$$ such that $$$(x_...
1024 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numCh...
Java
["7\n1 1\n1 2\n2 1\n2 2\n1 2\n1 3\n2 1"]
3.5 seconds
["1 2 4 4 4 6 3"]
null
Java 8
standard input
[ "data structures", "dsu", "divide and conquer" ]
feff009596baf8e2d7f1aac36b2f077e
The first line contains one integer $$$q$$$ ($$$1 \le q \le 3 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ lines follow, each containing two integers $$$x_i$$$, $$$y_i$$$ ($$$1 \le x_i, y_i \le 3 \cdot 10^5$$$), denoting $$$i$$$-th query as follows: if $$$(x_i, y_i) \in S$$$, erase it from $$$S$$$, otherwise in...
2,600
Print $$$q$$$ integers. $$$i$$$-th integer should be equal to the size of $$$E(S)$$$ after processing first $$$i$$$ queries.
standard output