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
324ebad86fd42af2c526a6e008082ef2
train_003.jsonl
1597415700
You are given an array $$$a_1, a_2, \dots , a_n$$$, which is sorted in non-decreasing order ($$$a_i \le a_{i + 1})$$$. Find three indices $$$i$$$, $$$j$$$, $$$k$$$ such that $$$1 \le i < j < k \le n$$$ and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class Temp { pub...
Java
["3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000"]
1 second
["2 3 6\n-1\n1 2 3"]
NoteIn the first test case it is impossible with sides $$$6$$$, $$$11$$$ and $$$18$$$. Note, that this is not the only correct answer.In the second test case you always can construct a non-degenerate triangle.
Java 8
standard input
[ "geometry", "math" ]
341555349b0c1387334a0541730159ac
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$)Β β€” the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \le n \le 5 \cdot 10^4$$$)Β β€” the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1...
800
For each test case print the answer to it in one line. If there is a triple of indices $$$i$$$, $$$j$$$, $$$k$$$ ($$$i < j < k$$$) such that it is impossible to construct a non-degenerate triangle having sides equal to $$$a_i$$$, $$$a_j$$$ and $$$a_k$$$, print that three indices in ascending order. If there are m...
standard output
PASSED
6ed5b12ebc221b1dcdd4163286b2cc1d
train_003.jsonl
1308582000
A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that walrus erase several letters from this string in order to get a new...
256 megabytes
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ char[] s1=sc.nextLine().toCharArray(); char[] s2=sc.nextLine().toCharArray(); int len=s1.length; int[][] visi...
Java
["abc\nxyz", "abcd\ndabc"]
2 seconds
["-1", "2"]
null
Java 8
standard input
[ "greedy", "strings" ]
1b83529ea4057c76ae8483f8aa506c56
The input data contain two lines. The first line contain the heading s1, the second line contains the word s2. The lines only consist of lowercase Latin letters (1 ≀ |s1| ≀ 104, 1 ≀ |s2| ≀ 106).
1,500
If it is impossible to get the word s2 in the above-described manner, print "-1" (without the quotes). Otherwise, print the least number of newspaper headings s1, which Fangy will need to receive the word s2.
standard output
PASSED
c604656d1f52c408650406ed8da30e58
train_003.jsonl
1308582000
A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that walrus erase several letters from this string in order to get a new...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { char[] s1 = sc.next().toCharArray(); char[] s2 = sc.next().toCharArray(); int len = s1.length; int[][...
Java
["abc\nxyz", "abcd\ndabc"]
2 seconds
["-1", "2"]
null
Java 8
standard input
[ "greedy", "strings" ]
1b83529ea4057c76ae8483f8aa506c56
The input data contain two lines. The first line contain the heading s1, the second line contains the word s2. The lines only consist of lowercase Latin letters (1 ≀ |s1| ≀ 104, 1 ≀ |s2| ≀ 106).
1,500
If it is impossible to get the word s2 in the above-described manner, print "-1" (without the quotes). Otherwise, print the least number of newspaper headings s1, which Fangy will need to receive the word s2.
standard output
PASSED
a579139f069cb4353f32c634bd8c7197
train_003.jsonl
1308582000
A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that walrus erase several letters from this string in order to get a new...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { char[] s1 = sc.next().toCharArray(); char[] s2 = sc.next().toCharArray(); int len = s1.length; int[][]...
Java
["abc\nxyz", "abcd\ndabc"]
2 seconds
["-1", "2"]
null
Java 8
standard input
[ "greedy", "strings" ]
1b83529ea4057c76ae8483f8aa506c56
The input data contain two lines. The first line contain the heading s1, the second line contains the word s2. The lines only consist of lowercase Latin letters (1 ≀ |s1| ≀ 104, 1 ≀ |s2| ≀ 106).
1,500
If it is impossible to get the word s2 in the above-described manner, print "-1" (without the quotes). Otherwise, print the least number of newspaper headings s1, which Fangy will need to receive the word s2.
standard output
PASSED
7651dd8caede49063d90cb9e362f1028
train_003.jsonl
1308582000
A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that walrus erase several letters from this string in order to get a new...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { char[] s1 = sc.next().toCharArray(); char[] s2 = sc.next().toCharArray(); int len = s1.length; int[][] ...
Java
["abc\nxyz", "abcd\ndabc"]
2 seconds
["-1", "2"]
null
Java 8
standard input
[ "greedy", "strings" ]
1b83529ea4057c76ae8483f8aa506c56
The input data contain two lines. The first line contain the heading s1, the second line contains the word s2. The lines only consist of lowercase Latin letters (1 ≀ |s1| ≀ 104, 1 ≀ |s2| ≀ 106).
1,500
If it is impossible to get the word s2 in the above-described manner, print "-1" (without the quotes). Otherwise, print the least number of newspaper headings s1, which Fangy will need to receive the word s2.
standard output
PASSED
888ea3a8a6262a0699bfc0618accf203
train_003.jsonl
1308582000
A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that walrus erase several letters from this string in order to get a new...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { char[] s1 = sc.next().toCharArray(); char[] s2 = sc.next().toCharArray(); int len = s1.length; int[][] find = new int[26][len + 1]; for (int j = 0; j < ...
Java
["abc\nxyz", "abcd\ndabc"]
2 seconds
["-1", "2"]
null
Java 8
standard input
[ "greedy", "strings" ]
1b83529ea4057c76ae8483f8aa506c56
The input data contain two lines. The first line contain the heading s1, the second line contains the word s2. The lines only consist of lowercase Latin letters (1 ≀ |s1| ≀ 104, 1 ≀ |s2| ≀ 106).
1,500
If it is impossible to get the word s2 in the above-described manner, print "-1" (without the quotes). Otherwise, print the least number of newspaper headings s1, which Fangy will need to receive the word s2.
standard output
PASSED
ba6cd3f36ca75c7c2eec22ad9c9a9c82
train_003.jsonl
1308582000
A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that walrus erase several letters from this string in order to get a new...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { char[] s1 = sc.next().toCharArray(); char[] s2 = sc.next().toCharArray(); int len = s1.length; int[][]...
Java
["abc\nxyz", "abcd\ndabc"]
2 seconds
["-1", "2"]
null
Java 8
standard input
[ "greedy", "strings" ]
1b83529ea4057c76ae8483f8aa506c56
The input data contain two lines. The first line contain the heading s1, the second line contains the word s2. The lines only consist of lowercase Latin letters (1 ≀ |s1| ≀ 104, 1 ≀ |s2| ≀ 106).
1,500
If it is impossible to get the word s2 in the above-described manner, print "-1" (without the quotes). Otherwise, print the least number of newspaper headings s1, which Fangy will need to receive the word s2.
standard output
PASSED
fea1a3a9411aed17c7f47ae7b2c1a036
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
//package practice.pset1; import java.io.*; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class R455F { static int[] arr6 = {3, 6, 1, 5, 4, 2}; static int[] arr7 = {7, 6, 1, 5, 4, 3, 2}; static int[] arr9 = {3, 6, 1, 5, 4, 7,...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
5d2f380dd33b812f8a47a58dfdefe2df
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
//package practice.pset1; import java.io.*; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class R455F_ { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw ...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
b5ca23f5a120d3bf93c14566dd95c5fb
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class ProblemE { static int mod = (int) (1e9+7); static InputReader in; static PrintWriter out; static int[] get(int n){ int[] a = new int[n + 1]; int x = 0; int l = Integer.toBinaryString(n).length(...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
5a2c2d1467753625555c0a9314497c51
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
import java.io.IOException; import java.util.*; public class Test { int readInt() { int ans = 0; boolean neg = false; try { boolean start = false; for (int c = 0; (c = System.in.read()) != -1; ) { if (c == '-') { start = true; ...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
fc79b7340fecce9020feb2832ec08734
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
import java.io.IOException; import java.util.*; public class Test { int readInt() { int ans = 0; boolean neg = false; try { boolean start = false; for (int c = 0; (c = System.in.read()) != -1; ) { if (c == '-') { start = true; ...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
d2455649d64a34fb023b2f3acf994341
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class ANDPermutations { void solve() { int n = in.nextInt(); findP(n); findQ(n); } ...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
fcaa51cdc68e8896dce318c4c801e8d1
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
import java.util.Scanner; public class F455 { @SuppressWarnings("resource") public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); if (n % 2 ==1){ System.out.println("NO"); }else{ System.out.println("YES"); int[] p = new int[n + 1]; int max = n;...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
5405dde530f9ae636f2121d706f4b7c8
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
import java.util.* ; import java.io.* ; public class AndPermutations2 { static int[] andZero(int n) { if(n%2!=0) return null ; else { int[] ans = new int[n+1] ; Arrays.fill(ans,-1) ; int maxLog = binlog(n) ; boolean allDone = false ; while(!allDone) { int maxTwo = (1<<maxLog) ; ...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
030bb83cc04423a4955d974eb247e214
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
import java.util.* ; public class AndPermutations { static int[] andZero(int n) { if(n%2!=0) return null ; else { int[] ans = new int[n+1] ; Arrays.fill(ans,-1) ; int maxLog = binlog(n) ; boolean allDone = false ; while(!allDone) { // System.out.println("maxLog :"+maxLog) ; int max...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
86ab01c37a98636a0c0fc42623797eeb
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; public class F_455 { public static final long[] POWER2 = generatePOWER2()...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
f5101bb487cb4199033d2e5e00a62a64
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
import java.util.Scanner; public class F { private static final int[] Q6 = {3, 6, 2, 5, 1, 4}; private static int N; public static void main(String[] args) { N = new Scanner(System.in).nextInt(); if (N % 2 == 0) { int[] p = new int[N + 1]; int max = N; ...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
943e75e3b7e5e920f16b2abcb0400855
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
//package round455; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.BitSet; import java.util.InputMismatchException; public class F { InputStream is; PrintWriter out; String INPUT = ""; void solve()...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
db7c10080aca216590a7fa27dc26b591
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
/* Keep solving problems. */ import java.util.*; import java.io.*; public class CFA { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; private static final long MOD = 1000 * 1000 * 1000 + 7; private static final int[] dx = {0, -1, 0, 1}; private static final int[] dy = ...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
cca7508fee202ce63d29572725607c73
train_003.jsonl
1514392500
Given an integer N, find two permutations: Permutation p of numbers from 1 to N such that pi ≠ i and pi &amp; i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that qi ≠ i and qi &amp; i ≠ 0 for all i = 1, 2, ..., N. &amp; is the bitwise AND operation.
256 megabytes
import java.io.*; import java.util.*; public class utkarsh{ BufferedReader br; PrintWriter out; void solve(){ br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int n = ni(); if(n%2 == 1){ out.println("NO"); }else{ out.println("YES"); int a[] = new ...
Java
["3", "6"]
2 seconds
["NO\nNO", "YES\n6 5 4 3 2 1 \nYES\n3 6 2 5 1 4"]
null
Java 8
standard input
[ "constructive algorithms" ]
581d08af78dc960f3212bdf01bc57167
The input consists of one line containing a single integer N (1 ≀ N ≀ 105).
2,500
For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and N elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.
standard output
PASSED
5345090651a4b6b0f3d640acc1e44bde
train_003.jsonl
1433595600
There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.The pr...
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.Bit...
Java
["3 1\n1 2 1", "3 1\n2 2 1", "6 3\n5 20 12 7 14 101"]
1 second
["Stannis", "Daenerys", "Stannis"]
NoteIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.In the second sample, if Stannis burns a city with two people, Daenerys ...
Java 7
standard input
[ "games" ]
67e51db4d96b9f7996aea73cbdba3584
The first line contains two positive space-separated integers, n and k (1 ≀ k ≀ n ≀ 2Β·105) β€” the initial number of cities in Westeros and the number of cities at which the game ends. The second line contains n space-separated positive integers ai (1 ≀ ai ≀ 106), which represent the population of each city in Westeros.
2,200
Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.
standard output
PASSED
f3f3ff2fb4b90e720e147e524899dc4c
train_003.jsonl
1433595600
There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.The pr...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces { public static void main(String[] args) throws IOException { Reader.init(System.in); int n = Reader.nextInt(), k = Reader.nextInt(); int odd = 0, even = 0; for(int i = 0; i < n; i++){ if(Reader.next...
Java
["3 1\n1 2 1", "3 1\n2 2 1", "6 3\n5 20 12 7 14 101"]
1 second
["Stannis", "Daenerys", "Stannis"]
NoteIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.In the second sample, if Stannis burns a city with two people, Daenerys ...
Java 7
standard input
[ "games" ]
67e51db4d96b9f7996aea73cbdba3584
The first line contains two positive space-separated integers, n and k (1 ≀ k ≀ n ≀ 2Β·105) β€” the initial number of cities in Westeros and the number of cities at which the game ends. The second line contains n space-separated positive integers ai (1 ≀ ai ≀ 106), which represent the population of each city in Westeros.
2,200
Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.
standard output
PASSED
a8a78b591b938fa187f9b552ea29850b
train_003.jsonl
1433595600
There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.The pr...
256 megabytes
import java.io.IOException; import java.io.InputStream; public class C { public static void main(String[] args) throws IOException { InputReader reader = new InputReader(System.in); int N = reader.readInt(); int K = reader.readInt(); long sum = 0; int odd = 0; int e...
Java
["3 1\n1 2 1", "3 1\n2 2 1", "6 3\n5 20 12 7 14 101"]
1 second
["Stannis", "Daenerys", "Stannis"]
NoteIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.In the second sample, if Stannis burns a city with two people, Daenerys ...
Java 7
standard input
[ "games" ]
67e51db4d96b9f7996aea73cbdba3584
The first line contains two positive space-separated integers, n and k (1 ≀ k ≀ n ≀ 2Β·105) β€” the initial number of cities in Westeros and the number of cities at which the game ends. The second line contains n space-separated positive integers ai (1 ≀ ai ≀ 106), which represent the population of each city in Westeros.
2,200
Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.
standard output
PASSED
75de1eccb5b4a4a56cecfae4d76453b8
train_003.jsonl
1433595600
There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.The pr...
256 megabytes
import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; public class Main { public static void main(String[] args) throws FileNotFoundException { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int k = in.nextInt(...
Java
["3 1\n1 2 1", "3 1\n2 2 1", "6 3\n5 20 12 7 14 101"]
1 second
["Stannis", "Daenerys", "Stannis"]
NoteIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.In the second sample, if Stannis burns a city with two people, Daenerys ...
Java 7
standard input
[ "games" ]
67e51db4d96b9f7996aea73cbdba3584
The first line contains two positive space-separated integers, n and k (1 ≀ k ≀ n ≀ 2Β·105) β€” the initial number of cities in Westeros and the number of cities at which the game ends. The second line contains n space-separated positive integers ai (1 ≀ ai ≀ 106), which represent the population of each city in Westeros.
2,200
Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.
standard output
PASSED
5494dd6d87c79c97b03370699d35d151
train_003.jsonl
1433595600
There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.The pr...
256 megabytes
//package loosery; 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 C { InputStream is; PrintWriter out; String INPUT = ""; void solve() { String[] name = {"St...
Java
["3 1\n1 2 1", "3 1\n2 2 1", "6 3\n5 20 12 7 14 101"]
1 second
["Stannis", "Daenerys", "Stannis"]
NoteIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.In the second sample, if Stannis burns a city with two people, Daenerys ...
Java 7
standard input
[ "games" ]
67e51db4d96b9f7996aea73cbdba3584
The first line contains two positive space-separated integers, n and k (1 ≀ k ≀ n ≀ 2Β·105) β€” the initial number of cities in Westeros and the number of cities at which the game ends. The second line contains n space-separated positive integers ai (1 ≀ ai ≀ 106), which represent the population of each city in Westeros.
2,200
Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.
standard output
PASSED
66f7e988e818509f75bae6bc12753bd1
train_003.jsonl
1433595600
There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.The pr...
256 megabytes
import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; import java.util.Set; /** * Created with IntelliJ IDEA. * User: igarus * Date: 22.05.15 * Time: 20:34 * To change this template use File | Settings | File Templates. */ public class LookseryCup2015C { public static void main(String[...
Java
["3 1\n1 2 1", "3 1\n2 2 1", "6 3\n5 20 12 7 14 101"]
1 second
["Stannis", "Daenerys", "Stannis"]
NoteIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.In the second sample, if Stannis burns a city with two people, Daenerys ...
Java 7
standard input
[ "games" ]
67e51db4d96b9f7996aea73cbdba3584
The first line contains two positive space-separated integers, n and k (1 ≀ k ≀ n ≀ 2Β·105) β€” the initial number of cities in Westeros and the number of cities at which the game ends. The second line contains n space-separated positive integers ai (1 ≀ ai ≀ 106), which represent the population of each city in Westeros.
2,200
Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.
standard output
PASSED
758b2ac7551ae518cb97ed02429f79f5
train_003.jsonl
1433595600
There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.The pr...
256 megabytes
import java.io.IOException; import java.util.InputMismatchException; public class TheGameOfParity { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt(); int K = sc.nextInt(); int odds = 0; int evns = 0; ...
Java
["3 1\n1 2 1", "3 1\n2 2 1", "6 3\n5 20 12 7 14 101"]
1 second
["Stannis", "Daenerys", "Stannis"]
NoteIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.In the second sample, if Stannis burns a city with two people, Daenerys ...
Java 7
standard input
[ "games" ]
67e51db4d96b9f7996aea73cbdba3584
The first line contains two positive space-separated integers, n and k (1 ≀ k ≀ n ≀ 2Β·105) β€” the initial number of cities in Westeros and the number of cities at which the game ends. The second line contains n space-separated positive integers ai (1 ≀ ai ≀ 106), which represent the population of each city in Westeros.
2,200
Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.
standard output
PASSED
f08a446b90cb360b401d61943d954ddb
train_003.jsonl
1433595600
There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.The pr...
256 megabytes
import java.io.IOException; import java.util.InputMismatchException; public class TheGameOfParity { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt(); int K = sc.nextInt(); int odds = 0; int evns = 0; for (int i = 0; i < N; i++) { int A = sc.nextInt...
Java
["3 1\n1 2 1", "3 1\n2 2 1", "6 3\n5 20 12 7 14 101"]
1 second
["Stannis", "Daenerys", "Stannis"]
NoteIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.In the second sample, if Stannis burns a city with two people, Daenerys ...
Java 7
standard input
[ "games" ]
67e51db4d96b9f7996aea73cbdba3584
The first line contains two positive space-separated integers, n and k (1 ≀ k ≀ n ≀ 2Β·105) β€” the initial number of cities in Westeros and the number of cities at which the game ends. The second line contains n space-separated positive integers ai (1 ≀ ai ≀ 106), which represent the population of each city in Westeros.
2,200
Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.
standard output
PASSED
5661d208c2b0e665b09a12c239c500f3
train_003.jsonl
1433595600
There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.The pr...
256 megabytes
import java.io.IOException; import java.util.InputMismatchException; public class TheGameOfParity { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt(); int K = sc.nextInt(); int odds = 0; int evns = 0; for (int i = 0; i < N; i++) { int A = sc.nextInt...
Java
["3 1\n1 2 1", "3 1\n2 2 1", "6 3\n5 20 12 7 14 101"]
1 second
["Stannis", "Daenerys", "Stannis"]
NoteIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.In the second sample, if Stannis burns a city with two people, Daenerys ...
Java 7
standard input
[ "games" ]
67e51db4d96b9f7996aea73cbdba3584
The first line contains two positive space-separated integers, n and k (1 ≀ k ≀ n ≀ 2Β·105) β€” the initial number of cities in Westeros and the number of cities at which the game ends. The second line contains n space-separated positive integers ai (1 ≀ ai ≀ 106), which represent the population of each city in Westeros.
2,200
Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.
standard output
PASSED
c2f7f858bb1eabd07e5c508c4387f8ce
train_003.jsonl
1433595600
There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.The pr...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; /** * Created by shamir0xe on 1/5/2015 AD. */ /* ID: shamir0xe PROG: gift1 LANG: JAVA */ public class Solution { public static void main(String[] args) { IOHandler IO = new IOHandler(); IO.init("std", "std", "input.txt"...
Java
["3 1\n1 2 1", "3 1\n2 2 1", "6 3\n5 20 12 7 14 101"]
1 second
["Stannis", "Daenerys", "Stannis"]
NoteIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.In the second sample, if Stannis burns a city with two people, Daenerys ...
Java 7
standard input
[ "games" ]
67e51db4d96b9f7996aea73cbdba3584
The first line contains two positive space-separated integers, n and k (1 ≀ k ≀ n ≀ 2Β·105) β€” the initial number of cities in Westeros and the number of cities at which the game ends. The second line contains n space-separated positive integers ai (1 ≀ ai ≀ 106), which represent the population of each city in Westeros.
2,200
Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.
standard output
PASSED
45d1a0c2eb4c69439e350ef4ec0de6a6
train_003.jsonl
1557930900
This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You m...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.*; import java.io.*; public class Tree { static int check(long w, long b, int a[]) { int A[] = {4,8,15,16,23,42}; int B[] = new int[100001]; ...
Java
["16\n64\n345\n672"]
1 second
["? 1 1\n? 2 2\n? 3 5\n? 4 6\n! 4 8 15 16 23 42"]
NoteIf you want to submit a hack for this problem, your test should contain exactly six space-separated integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_6$$$. Each of $$$6$$$ special numbers should occur exactly once in the test. The test should be ended with a line break character.
Java 8
standard input
[ "math", "divide and conquer", "brute force", "interactive" ]
c0f79d7ebcecc4eb7d07c372ba9be802
null
1,400
null
standard output
PASSED
661c1475c00dfe249307a06ef7b917e2
train_003.jsonl
1557930900
This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You m...
256 megabytes
import java.util.*; public class E1167B { static final int ALL_PRODUCTS = 7418880; // 4 * 8 * 15 * 16 * 23 * 42 static int [] a12 = new int [2]; static int [] a34 = new int [2]; static int [] a13 = new int [2]; static int get_common( int i1, int i2, int i3, int i4) { if (i1 == i3...
Java
["16\n64\n345\n672"]
1 second
["? 1 1\n? 2 2\n? 3 5\n? 4 6\n! 4 8 15 16 23 42"]
NoteIf you want to submit a hack for this problem, your test should contain exactly six space-separated integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_6$$$. Each of $$$6$$$ special numbers should occur exactly once in the test. The test should be ended with a line break character.
Java 8
standard input
[ "math", "divide and conquer", "brute force", "interactive" ]
c0f79d7ebcecc4eb7d07c372ba9be802
null
1,400
null
standard output
PASSED
e33f30707b13d24b010c2e32249e8a16
train_003.jsonl
1557930900
This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You m...
256 megabytes
import java.util.Scanner; /* 966 672 630 336 */ /** * * @author Andy Phan */ public class p1167b { static int[] arr = {4, 8, 15, 16, 23, 42}; public static void main(String[] args) { Scanner in = new Scanner(System.in); int[] has = new int[1000]; for(int i = 0; i < 6; i++) has[arr...
Java
["16\n64\n345\n672"]
1 second
["? 1 1\n? 2 2\n? 3 5\n? 4 6\n! 4 8 15 16 23 42"]
NoteIf you want to submit a hack for this problem, your test should contain exactly six space-separated integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_6$$$. Each of $$$6$$$ special numbers should occur exactly once in the test. The test should be ended with a line break character.
Java 8
standard input
[ "math", "divide and conquer", "brute force", "interactive" ]
c0f79d7ebcecc4eb7d07c372ba9be802
null
1,400
null
standard output
PASSED
b0484e505f8d5f810537b7b2d1e11fd6
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.*; import java.util.*; import static java.util.Collections.*; import static java.lang.Math.*; @SuppressWarnings("unchecked") public class A_Boredom { public static PrintWriter out; public static InputReader in; public static long[] dp; public static int n; public static ArrayList<Lon...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
b01e48a170438a51b376675b2705bd2e
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.util.*; import java.io.*; public class Main { static PrintWriter out; static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ br=new BufferedReader(new InputStreamReader(System.in)); out=new PrintWriter(System.out); } String next(){ while(st==nu...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
e524749d723761f41ab39657f4d65408
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.util.*; import java.io.*; public class Main { static PrintWriter out; static class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ br=new BufferedReader(new InputStreamReader(System.in)); out=new PrintWriter(System.out); } String next(){ while(st==nu...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
e07177988c932a4835bb160dba9d7e98
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Boredom455A { public static void main(String[] args) { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); final int max = 100003; int t = sc.nextInt(); lo...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
d7a6ffbb28bbc43372296091aa7b14f2
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; ...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
02f7dcb98c696237ad2a8e249c2b9c62
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class ar { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { ...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
558ccc13f8cd316698cbcb4b0856c0b1
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class CF455A { static BufferedReader __in; static PrintWriter __out; static StringTokenizer input; public static void main(String[] args) throws IOException { __in = new BufferedRead...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
f2e182d6b3b7991d809fa37cfcc3bf66
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.InputMismatchException; public class B { public static int[] freq; public static long[] dp; public static void main(String[] args) throws Exception { // TODO Auto-genera...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
697495916fdadf219862f6fb6528a1f1
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.util.Scanner; public class Boredom { public static void main(String[] args) { // TODO Auto-generated method stub Scanner t = new Scanner(System.in); int n = t.nextInt(); long[] in = new long[100003]; long[] ans = new long[100003]; for (int i = 0; i < n; i++) in[t.nextInt()]++; ans[0] =...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
d764f27477f6ee9d7ec6a4bd2f47fcf1
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
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.FileReader; import java.io.InputStreamReader; import java.io.InputStream; ...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
76d3bcfb1a5f14bec47d607fff12815c
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class test { public static void main(String[] args) { // int test = fs.nextInt(); int test = 1; for (int cases = 0; cases < test; cases++) { int n = fs.nextInt(); long a[]=new long[100001]; int max=0; for (int i = 0; i < n; i++) { ...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
0ed8ddec6bc30107aa013cf8831c9b4a
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.*; import java.util.*; public class Main{ public static void main(String []args)throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out)); /*int t=Integer.parseInt(br.re...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
db7b28cc7a6ad793fadd2b6b95d549ce
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.IOException; import java.util.Scanner; public class Boredom { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long arr[] = new long[100001], dp[] = new long[100001]; int i = 0; for(i = 0...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
307c108fc63f37f0d5d2804af4cda5f7
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
// import java.io.IOException; // import java.util.Scanner; // public class Boredom { // public static void main(String[] args) throws IOException { // Scanner sc = new Scanner(System.in); // int n = sc.nextInt(); // long arr[] = new long[100001], dp[] = new long[100001]; // int i...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
c4918941456db2a0a8d0cd314acf5e83
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.IOException; import java.util.Scanner; public class Boredom { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long arr[] = new long[100001], dp[] = new long[100001]; int i = 0; for(i = 0...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
0fa5617dda328e5d50d9cf666ef8451c
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Scanner; public class scratch_16{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n =sc.nextInt(); long arr[]= new long[100001]; for (int i = 0; i <n ; i++) { int x= sc.nextIn...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
aeeb1477812d60e30df8872d7aa4b2e9
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); // br = new BufferedReader(new FileRea...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
e75f1a06681d4580fed687c7a2933022
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
//package test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; public class compete { public static void main(String[] args) throws IOException{ BufferedRead...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
7216a60420b264d2515c278177602d12
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Boredom { int n, size; int[] a; public static void main(final String[] args) throws IOException { final BufferedReader bufferedReader = new BufferedReader(new InputStre...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
2a4b264a0d75d9e4d3e1e118676c7b39
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.util.*; public class P455A { private final static int MOD = 1_000_000_007; public static long mod(long a, long b) { return ((a % b) + b ) % b; } public static int mod (int a, int b) { return ((a % b) + b ) % b; } public static void main(String[] args) { ...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
c0f83f572477a198fdb2b3df80a71e07
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.*; import java.util.*; public final class cf { static long dp[]; static int n; static HashMap<Integer,Integer>map; public static void main(String[] args) throws Exception { BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescrip...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
5faab395b5b4078105ada8cf229ced70
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class ladders455a { static BufferedReader __in; static PrintWriter __out; static StringTokenizer input; public static void main(String[] args) throws IOException { __in = new Buffere...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
720cc421dbb0445c8c863f85b21fb1a6
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.*; import java.util.*; public class Main { private static void solver(InputReader sc, PrintWriter out) throws Exception { int n = sc.nextInt(); long arr[] = new long[100001]; for (int i = 0; i < n; i++) { arr[sc.nextInt()]++; ...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
24287d593526c9c53c95d927114ac303
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author GodOfWar */ public class Dp0 { public static void main(String[] args) {// 1 1 ...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
b373b08056d8fdf7f84ddb035fe02752
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) throws IOException { // br = new BufferedReader(new FileReader(new File("input.txt"))); // out = new PrintWriter(new File("output.txt")); br = new BufferedReader(...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
43040f5be5f36b22438f0c68da6cd4e0
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.*; import java.util.*; public class Q2 { public static void main(String[] args)throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String[] ss=br.readLine().split(" "); int n=Integer.parseInt(ss[0]); ss=br.readLine().split("...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
a0b83a2ec82e71fbb2613d02facba5a3
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import javax.print.DocFlavor; import java.awt.*; import java.io.*; import java.math.*; import java.util.*; public class Codeforce { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStr...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
70c55e381cfc8cffda89316f510513e8
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.util.Scanner; public class boredom { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int n = s.nextInt(); long arr[] = new long[100001]; for(int i = 0;i<n;++i) { int k = s.nextInt(); arr[k] += k; } long inc = 0...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
5458881f29ab8e01e277354c7f671992
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.*; import java.util.*; public class A455 { static Scanner sc; public static void main(String args[])throws IOException{ sc = new Scanner(System.in); int t = 1; while(t-->0){ solve(); } } static void solve(){ int n = sc.nextInt(); ...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
2807a0aaff6b89e37582e8c1745d5e7a
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashSet; import java.util.TreeSet; public class practice_DP { static Reader r = new Reader(); st...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
f504ac78eb3556bcde4d9f726647db5a
train_003.jsonl
1407511800
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it ak) and d...
256 megabytes
/* Modassir_Ali algo.java */ import java.util.*; import java.io.*; import java.util.Stack ; import java.util.HashSet; import java.util.HashMap; public class A_CF260D1 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() ...
Java
["2\n1 2", "3\n1 2 3", "9\n1 2 1 3 2 2 2 2 3"]
1 second
["2", "4", "10"]
NoteConsider the third test example. At first step we need to choose any element equal to 2. After that step our sequence looks like this [2, 2, 2, 2]. Then we do 4 steps, on each step we choose any element equals to 2. In total we earn 10 points.
Java 11
standard input
[ "dp" ]
41b3e726b8146dc733244ee8415383c0
The first line contains integer n (1 ≀ n ≀ 105) that shows how many numbers are in Alex's sequence. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 105).
1,500
Print a single integer β€” the maximum number of points that Alex can earn.
standard output
PASSED
2cbe28526758d1abff34e286d1380c87
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
// 4 8 15 16 23 42 // 4 7 1 7 19 // 3 3 10 // 2 3 6 //package com.company; import java.util.*; public class Main { public static void main(String[] args) { // write your code here Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[][] pairs = new int[n][2]; f...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
e3e6c7716693f1b6d1c237a3a6a4a520
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.util.*; import java.math.*; // **** E. Culture Code **** public class E { static char [] in = new char [1000000]; static long MOD = 1000000007L; public static void main (String [] arg) throws Throwable { int n = nextInt(); Pair [] M = new Pair [n]; for (int i =0; i<n; ++i) { int out = nextInt(...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
836aa9508e8ae73cbcad7b3452daf0fe
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; /* Author: rahejamehul Date: 8/10/2019 */ public class E2 { static long MOD = 1000000007; public static void main(String[] args) throws Exception { Reader br = new Reader(); PrintWriter out = new PrintWriter(Syste...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
2b96cb0138553a22e8b279924068db9b
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
//package codeforces_edu69; import java.io.*; import java.util.*; public class E3 { public static void main(String[] args) { int N = IO.nextInt(); List<Doll> dolls = new ArrayList<>(); for (int i = 0; i < N; i++) { Doll p = new Doll(IO.nextInt(), IO.nextInt()); do...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
c52b1eb5ca9c4e78d2e0828a459a515a
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
//package codeforces_edu69; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.stream.Collectors; public class E2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStr...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
440b95baa73e876c923769a98701c431
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
// practice with rainboy import java.io.*; import java.util.*; public class CF1197E extends PrintWriter { CF1197E() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1197E o = new CF1197E(); o.main(); o.flush(); } static final int INF = 0x3f3f3f3f, MD = 1...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
b497ba12d398e85e7e9258f6cedcba5e
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.io.*; import java.util.*; public class Solution { long mod = 1000000007L; private void solve() throws Exception { int n = nextInt(); Volume[] out = new Volume[n]; Volume[] in = new Volume[n]; for(int i = 0; i < n; i++) { out[i] = new Volume(i, nextLong()); in[i] = new Volume(i, nextL...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
bf64e1e609a20c78c9b53e173a0dd425
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.io.*; import java.util.*; public class Solution { long mod = 1000000007L; private void solve() throws Exception { int n = nextInt(); Volume[] out = new Volume[n]; Volume[] in = new Volume[n]; for(int i = 0; i < n; i++) { out[i] = new Volume(i, nextLong()); in[i] = new Volume(i, next...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
56311cf66807b6e7dca4dbb3cd42a673
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.io.*; import java.util.*; public class E { // ------------------------ static class O implements Comparable<O>{ int out,in,idx; public O(int o,int i,int d){ out=o; in=i; idx=d; } public int compareTo(O other){ if(other.out==out&&other.in==in) return idx-other.idx; if(other.out...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
36f2087eb0ebeaf83cb0177fb7373e7a
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.io.*; import java.util.*; public class A { static long INF = (long) 1e18; static class pair { int in, out; pair(int a, int b) { in = b; out = a; } } static int MOD = (int) 1e9 + 7; public static void main(String[] args) throws IOException { Scanner sc = new Scanner(); PrintWrite...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
a7a2f49c0c21dd1b1177a8538db1b499
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
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.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.Writer; import java.io.OutputStream...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
2507b57f222cc0b95b3bdfe751a1b30d
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class Main { static int inf = (int) 1e9 + 7; public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(System.out); int n = nex...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
ab1aa7765a9dc920eb59ef93477a1e97
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.charset.Charset; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Random; import java.util.stream.Collectors; public...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
5a8e0b9d439ffdaedc8beef05298a1c4
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Comparator.*; public class Main { FastScanner in; PrintWriter out; boolean multitests = false; long mod = (long) 1e9 + 7; // 998_244_353L || (long) 1e9 + 9 ArrayList<Inte...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
d66609885d476748f850fcd83e25224b
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Comparator.*; public class Main { FastScanner in; PrintWriter out; boolean multitests = false; long mod = (long) 1e9 + 7; // 998_244_353L || (long) 1e9 + 9 ArrayList<Inte...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
80a14507df5ec00e9beff238b1506a44
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class E { private static final long MOD=(long) (1e9+7); static class Pair implements Comparable<Pair> { long f, s; Pair(long f, long s){this.f = f;this.s = s;} public int compareTo(Pair b){return Long.compare(this.s...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
2e2d58ce6f68285e94ae6aabc85c0bd0
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class E { private static final long MOD=(long) (1e9+7); static class Pair implements Comparable<Pair> { long f, s; Pair(long f, long s){this.f = f;this.s = s;} public int compareTo(Pair b){return Long.compare(this.s...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
322be64a92ad0e5e456d2e06f8a88d71
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; public class Main{ //SOLUTION BEGIN //Into the Hardware Mode void pre() throws Exception{} void solve(int TC) throws Exception{ int n = ni(); long[][] p = new long[n][]; for(int i = 0; i< n; i++)p[i] = new long[]{nl(), nl(...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
f7f82af5b898238e1b0baf33525ab556
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
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.InputMismatchException; import java.io.IOException; import java.util.Collections; import java.util.TreeSet; import java.util.ArrayList; import java.io.InputStream; ...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
3f1250f74a22a738e7f5fc3bae23075b
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
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.InputMismatchException; import java.io.IOException; import java.util.Collections; import java.util.TreeSet; import java.util.ArrayList; import java.io.InputStream; ...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
a9ad5380ae4aedeea07285624c411d0b
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
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.InputMismatchException; import java.io.IOException; import java.util.Collections; import java.util.TreeSet; import java.util.ArrayList; import java.io.InputStream; ...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
056fdacf69a5d74d8635745d0a487bb3
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.io.*; import java.util.*; public class E implements Runnable { public static void main (String[] args) {new Thread(null, new E(), "_cf", 1 << 28).start();} public void run() { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); System.err.println(""); int n = fs.n...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
ea53eb50f4f8633823d1e603d2eabadf
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
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.io.Writer; import java.io.OutputStreamWri...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
183125326e6c6ff06f08dfcd57a4c484
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.util.*; import java.math.*; public class Solution{ private int mod = (int)Math.pow(10, 9) + 7; private int [][] st; private int n; private void solve(){ Scanner sc = new Scanner(System.in); this.n = sc.nextInt(); int [][] dolls = new int[n][2]; for(int i = 0; ...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
a7486f28b3ce43f6b366394f332ade1a
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.util.*; import java.math.*; public class Solution{ private int mod = (int)Math.pow(10, 9) + 7; private int [][] st; private int n; private void solve(){ Scanner sc = new Scanner(System.in); this.n = sc.nextInt(); int [][] dolls = new int[n][2]; for(int i = 0; ...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
a68c6514b9348a4e671c4e8e7dd6062a
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
import java.lang.*; import java.math.*; import java.util.*; import java.io.*; public class Main { class Pair implements Comparable<Pair> { long in; long out; public Pair(long out, long in) { this.in = in; this.out = out; } public int compareTo(Pair ...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
f9087f232d1fd7dd5b3c83c3c241b597
train_003.jsonl
1563806100
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has $$$n$$$ different matryoshkas. Any matryoshka is a figure of volume $$$out_i$$$ with an empty space inside of volume $$$in_i$$$ (of course, $$$out_i &gt; in_i$$$).You ...
256 megabytes
/** * Created by Aminul on 7/23/2019. */ import org.omg.CORBA.INTERNAL; import sun.reflect.generics.tree.Tree; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import static java.lang.Math.*; public class E_3 { static final long mod = (long) 1e9 + 7, inf ...
Java
["7\n4 1\n4 2\n4 2\n2 1\n5 4\n6 4\n3 2"]
2 seconds
["6"]
NoteThere are $$$6$$$ big enough nested subsets with minimum possible extra space in the example: $$$\{1, 5\}$$$: we can't add any other matryoshka and keep it nested; it's extra space is $$$1$$$; $$$\{1, 6\}$$$; $$$\{2, 4, 5\}$$$; $$$\{2, 4, 6\}$$$; $$$\{3, 4, 5\}$$$; $$$\{3, 4, 6\}$$$. There are no more "good"...
Java 8
standard input
[ "dp", "combinatorics", "shortest paths", "sortings", "data structures", "binary search" ]
d8c2cb03579142f45d46f1fe22a9b8c0
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of matryoshkas. The next $$$n$$$ lines contain a description of each doll: two integers $$$out_i$$$ and $$$in_i$$$ ($$$1 \le in_i &lt; out_i \le 10^9$$$) β€” the outer and inners volumes of the $$$i$$$-th matryoshka.
2,300
Print one integer β€” the number of big enough nested subsets such that extra space of each of these subsets is minimum possible. Since the answer can be large, print it modulo $$$10^9 + 7$$$.
standard output
PASSED
8a6cc48f844b7ee50b1c22c2111aa6ec
train_003.jsonl
1522850700
Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak, i, j; 1 being ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.lang.*; public class Main { private static FastReader sc = new FastReader(System.in); private static OutputWriter out = new OutputWriter(System.out); public static void main(String[] args) throws Exception { int n = sc.nextInt()...
Java
["1\n0\n\n0\n\n1\n\n0", "3\n101\n010\n101\n\n101\n000\n101\n\n010\n101\n011\n\n010\n101\n010"]
1 second
["1", "2"]
null
Java 8
standard input
[ "implementation", "bitmasks", "brute force" ]
dc46c6cb6b4b9b5e7e6e5b4b7d034874
The first line contains odd integer n (1 ≀ n ≀ 100) β€” the size of all pieces of the board. Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty li...
1,400
Print one number β€” minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.
standard output
PASSED
6a2fc348d6ea9904a6a26feb27a00ae1
train_003.jsonl
1522850700
Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak, i, j; 1 being ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { static PrintWriter out=new PrintWriter(System.out);static FastScanner in = new FastScanner(System.in);static class FastScanner {BufferedReader br;StringTokenizer stok;FastScanner(InputStream is) {br = new BufferedReader(new InputStr...
Java
["1\n0\n\n0\n\n1\n\n0", "3\n101\n010\n101\n\n101\n000\n101\n\n010\n101\n011\n\n010\n101\n010"]
1 second
["1", "2"]
null
Java 8
standard input
[ "implementation", "bitmasks", "brute force" ]
dc46c6cb6b4b9b5e7e6e5b4b7d034874
The first line contains odd integer n (1 ≀ n ≀ 100) β€” the size of all pieces of the board. Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty li...
1,400
Print one number β€” minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.
standard output
PASSED
b5f6bef137dd8078132379fb18a3fedc
train_003.jsonl
1522850700
Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak, i, j; 1 being ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.StringTokenizer; public class Main { private static int N; private static int[][] standard1, standard2, board; private static ArrayList<int[]> permutati...
Java
["1\n0\n\n0\n\n1\n\n0", "3\n101\n010\n101\n\n101\n000\n101\n\n010\n101\n011\n\n010\n101\n010"]
1 second
["1", "2"]
null
Java 8
standard input
[ "implementation", "bitmasks", "brute force" ]
dc46c6cb6b4b9b5e7e6e5b4b7d034874
The first line contains odd integer n (1 ≀ n ≀ 100) β€” the size of all pieces of the board. Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty li...
1,400
Print one number β€” minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.
standard output
PASSED
a3891c241d0fa8695f316fd05313ed6d
train_003.jsonl
1522850700
Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak, i, j; 1 being ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class Main { private static int N; private static int[][] standard1, standard2, board; private static ArrayList<int[]> permutations = new ArrayList<int[]>...
Java
["1\n0\n\n0\n\n1\n\n0", "3\n101\n010\n101\n\n101\n000\n101\n\n010\n101\n011\n\n010\n101\n010"]
1 second
["1", "2"]
null
Java 8
standard input
[ "implementation", "bitmasks", "brute force" ]
dc46c6cb6b4b9b5e7e6e5b4b7d034874
The first line contains odd integer n (1 ≀ n ≀ 100) β€” the size of all pieces of the board. Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty li...
1,400
Print one number β€” minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.
standard output
PASSED
03eed3291f350be7ff57ba1509f18d0e
train_003.jsonl
1522850700
Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak, i, j; 1 being ...
256 megabytes
import java.util.*; public class Main { static final int maxn = 110; static final int dead = 0x7f7f7f7f; public static void main(String[] args) { Scanner in = new Scanner(System.in); int[] cout=new int[5]; int n=in.nextInt(); String temp; for(int i=1;i<=4;i++){ for(int j=1;j<=n;j++) { temp=in.ne...
Java
["1\n0\n\n0\n\n1\n\n0", "3\n101\n010\n101\n\n101\n000\n101\n\n010\n101\n011\n\n010\n101\n010"]
1 second
["1", "2"]
null
Java 8
standard input
[ "implementation", "bitmasks", "brute force" ]
dc46c6cb6b4b9b5e7e6e5b4b7d034874
The first line contains odd integer n (1 ≀ n ≀ 100) β€” the size of all pieces of the board. Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty li...
1,400
Print one number β€” minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.
standard output
PASSED
770e53aa2e238c365c73d513d80269e7
train_003.jsonl
1522850700
Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak, i, j; 1 being ...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { FastReader fr =new FastReader(); OutputStream outputStream = System.out; PrintWriter out = new PrintWriter(outputStream); int n = fr.nextInt();...
Java
["1\n0\n\n0\n\n1\n\n0", "3\n101\n010\n101\n\n101\n000\n101\n\n010\n101\n011\n\n010\n101\n010"]
1 second
["1", "2"]
null
Java 8
standard input
[ "implementation", "bitmasks", "brute force" ]
dc46c6cb6b4b9b5e7e6e5b4b7d034874
The first line contains odd integer n (1 ≀ n ≀ 100) β€” the size of all pieces of the board. Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty li...
1,400
Print one number β€” minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.
standard output
PASSED
44ff8616e65123add58c0416052b87f2
train_003.jsonl
1522850700
Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak, i, j; 1 being ...
256 megabytes
import java.util.*; import java.io.*; public class hell { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() {...
Java
["1\n0\n\n0\n\n1\n\n0", "3\n101\n010\n101\n\n101\n000\n101\n\n010\n101\n011\n\n010\n101\n010"]
1 second
["1", "2"]
null
Java 8
standard input
[ "implementation", "bitmasks", "brute force" ]
dc46c6cb6b4b9b5e7e6e5b4b7d034874
The first line contains odd integer n (1 ≀ n ≀ 100) β€” the size of all pieces of the board. Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty li...
1,400
Print one number β€” minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.
standard output
PASSED
e115fb6cb5effc07733e8125a10c8e7f
train_003.jsonl
1522850700
Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak, i, j; 1 being ...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class Codeforces { public static void main(String[] args) { TaskC Solver = new TaskC(); Solver.Solve(); } private static class TaskC { private void Solve() { Scanner in = new Scanner(System.in...
Java
["1\n0\n\n0\n\n1\n\n0", "3\n101\n010\n101\n\n101\n000\n101\n\n010\n101\n011\n\n010\n101\n010"]
1 second
["1", "2"]
null
Java 8
standard input
[ "implementation", "bitmasks", "brute force" ]
dc46c6cb6b4b9b5e7e6e5b4b7d034874
The first line contains odd integer n (1 ≀ n ≀ 100) β€” the size of all pieces of the board. Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty li...
1,400
Print one number β€” minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.
standard output