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
f8da26a320ecc25a2801c3d87d58dc7d
train_002.jsonl
1589466900
You are given an array $$$a$$$ of length $$$n$$$ consisting of zeros. You perform $$$n$$$ actions with this array: during the $$$i$$$-th action, the following sequence of operations appears: Choose the maximum by length subarray (continuous subsegment) consisting only of zeros, among all such segments choose the leftm...
256 megabytes
import java.util.*; import java.io.*; public final class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); int[] arr = new int[n]; PriorityQueue<int[]> pq = new ...
Java
["6\n1\n2\n3\n4\n5\n6"]
1 second
["1 \n1 2 \n2 1 3 \n3 1 2 4 \n2 4 1 3 5 \n3 4 1 5 2 6"]
null
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings" ]
25fbe21a449c1ab3eb4bdd95a171d093
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases...
1,600
For each test case, print the answer — the array $$$a$$$ of length $$$n$$$ after performing $$$n$$$ actions described in the problem statement. Note that the answer exists and unique.
standard output
PASSED
34299b84b1eedfc288ccb27e5fd73e80
train_002.jsonl
1589466900
You are given an array $$$a$$$ of length $$$n$$$ consisting of zeros. You perform $$$n$$$ actions with this array: during the $$$i$$$-th action, the following sequence of operations appears: Choose the maximum by length subarray (continuous subsegment) consisting only of zeros, among all such segments choose the leftm...
256 megabytes
import java.util.*; import java.io.*; public final class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = ...
Java
["6\n1\n2\n3\n4\n5\n6"]
1 second
["1 \n1 2 \n2 1 3 \n3 1 2 4 \n2 4 1 3 5 \n3 4 1 5 2 6"]
null
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings" ]
25fbe21a449c1ab3eb4bdd95a171d093
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases...
1,600
For each test case, print the answer — the array $$$a$$$ of length $$$n$$$ after performing $$$n$$$ actions described in the problem statement. Note that the answer exists and unique.
standard output
PASSED
0389e8c7c5aad1e47e9c17d2dc5f5850
train_002.jsonl
1589466900
You are given an array $$$a$$$ of length $$$n$$$ consisting of zeros. You perform $$$n$$$ actions with this array: during the $$$i$$$-th action, the following sequence of operations appears: Choose the maximum by length subarray (continuous subsegment) consisting only of zeros, among all such segments choose the leftm...
256 megabytes
import java.util.*; import java.io.*; /** * @author Azuz * */ public class Main { void solve(Scanner in, PrintWriter out) { int tt = in.nextInt(); while (tt-->0) { int n = in.nextInt(); PriorityQueue<Tuple> q = new PriorityQueue<>(); q.offer(new Tuple(0, n - 1, n)); ...
Java
["6\n1\n2\n3\n4\n5\n6"]
1 second
["1 \n1 2 \n2 1 3 \n3 1 2 4 \n2 4 1 3 5 \n3 4 1 5 2 6"]
null
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings" ]
25fbe21a449c1ab3eb4bdd95a171d093
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases...
1,600
For each test case, print the answer — the array $$$a$$$ of length $$$n$$$ after performing $$$n$$$ actions described in the problem statement. Note that the answer exists and unique.
standard output
PASSED
be0eedad3fd51ae9d53e695088c3ed79
train_002.jsonl
1589466900
You are given an array $$$a$$$ of length $$$n$$$ consisting of zeros. You perform $$$n$$$ actions with this array: during the $$$i$$$-th action, the following sequence of operations appears: Choose the maximum by length subarray (continuous subsegment) consisting only of zeros, among all such segments choose the leftm...
256 megabytes
import java.io.*; import java.util.*; import javax.management.Query; import javax.swing.Box.Filler; public class prop { static Scanner sc; static PrintWriter pw; static int a[]; static int n; static boolean v[]; static int x = 1; static class pair implements Comparable<pair> { int x, y; pair(int i, int ...
Java
["6\n1\n2\n3\n4\n5\n6"]
1 second
["1 \n1 2 \n2 1 3 \n3 1 2 4 \n2 4 1 3 5 \n3 4 1 5 2 6"]
null
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings" ]
25fbe21a449c1ab3eb4bdd95a171d093
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases...
1,600
For each test case, print the answer — the array $$$a$$$ of length $$$n$$$ after performing $$$n$$$ actions described in the problem statement. Note that the answer exists and unique.
standard output
PASSED
a0fe6b13f4738711704a890f14d14834
train_002.jsonl
1589466900
You are given an array $$$a$$$ of length $$$n$$$ consisting of zeros. You perform $$$n$$$ actions with this array: during the $$$i$$$-th action, the following sequence of operations appears: Choose the maximum by length subarray (continuous subsegment) consisting only of zeros, among all such segments choose the leftm...
256 megabytes
import java.util.*; import java.io.*; public class ConstructingTheArray { 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...
Java
["6\n1\n2\n3\n4\n5\n6"]
1 second
["1 \n1 2 \n2 1 3 \n3 1 2 4 \n2 4 1 3 5 \n3 4 1 5 2 6"]
null
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings" ]
25fbe21a449c1ab3eb4bdd95a171d093
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases...
1,600
For each test case, print the answer — the array $$$a$$$ of length $$$n$$$ after performing $$$n$$$ actions described in the problem statement. Note that the answer exists and unique.
standard output
PASSED
a048afc32183cda9b4389601b816a9bf
train_002.jsonl
1589466900
You are given an array $$$a$$$ of length $$$n$$$ consisting of zeros. You perform $$$n$$$ actions with this array: during the $$$i$$$-th action, the following sequence of operations appears: Choose the maximum by length subarray (continuous subsegment) consisting only of zeros, among all such segments choose the leftm...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i < t; i++) { int n = sc.nextInt(); int l = 1, r = n; Queue<int[]> q = new PriorityQueue<>((a,b) -> b[2] == a[2] ? a[0] - b[0] : b[2] - a[2]); int...
Java
["6\n1\n2\n3\n4\n5\n6"]
1 second
["1 \n1 2 \n2 1 3 \n3 1 2 4 \n2 4 1 3 5 \n3 4 1 5 2 6"]
null
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings" ]
25fbe21a449c1ab3eb4bdd95a171d093
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases...
1,600
For each test case, print the answer — the array $$$a$$$ of length $$$n$$$ after performing $$$n$$$ actions described in the problem statement. Note that the answer exists and unique.
standard output
PASSED
0fd711fbc30d299ec0d49192f25c1332
train_002.jsonl
1589466900
You are given an array $$$a$$$ of length $$$n$$$ consisting of zeros. You perform $$$n$$$ actions with this array: during the $$$i$$$-th action, the following sequence of operations appears: Choose the maximum by length subarray (continuous subsegment) consisting only of zeros, among all such segments choose the leftm...
256 megabytes
import java.util.*;import java.io.*;import java.math.*; public class Main { static class Node{ int l,r,dist; public Node(int l,int r){ this.l=l; this.r=r; dist=(r-l+1); } } static public class sortByDist implements Comparator<Node>{ public int compare(Node A,Node B){ if(A.dist==B.dist) ...
Java
["6\n1\n2\n3\n4\n5\n6"]
1 second
["1 \n1 2 \n2 1 3 \n3 1 2 4 \n2 4 1 3 5 \n3 4 1 5 2 6"]
null
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings" ]
25fbe21a449c1ab3eb4bdd95a171d093
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases...
1,600
For each test case, print the answer — the array $$$a$$$ of length $$$n$$$ after performing $$$n$$$ actions described in the problem statement. Note that the answer exists and unique.
standard output
PASSED
06ba355b3239fed7a8f2f69ee771a3e3
train_002.jsonl
1589466900
You are given an array $$$a$$$ of length $$$n$$$ consisting of zeros. You perform $$$n$$$ actions with this array: during the $$$i$$$-th action, the following sequence of operations appears: Choose the maximum by length subarray (continuous subsegment) consisting only of zeros, among all such segments choose the leftm...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class D { static class Pair{ int l,r,len; public Pair(int l,int r){ this.l = l; this.r = r; len = r - l +1; } } public static void process()throws IOException { int n =...
Java
["6\n1\n2\n3\n4\n5\n6"]
1 second
["1 \n1 2 \n2 1 3 \n3 1 2 4 \n2 4 1 3 5 \n3 4 1 5 2 6"]
null
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings" ]
25fbe21a449c1ab3eb4bdd95a171d093
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases...
1,600
For each test case, print the answer — the array $$$a$$$ of length $$$n$$$ after performing $$$n$$$ actions described in the problem statement. Note that the answer exists and unique.
standard output
PASSED
ed3d884a736344c84f977c3b4d8b78b1
train_002.jsonl
1589466900
You are given an array $$$a$$$ of length $$$n$$$ consisting of zeros. You perform $$$n$$$ actions with this array: during the $$$i$$$-th action, the following sequence of operations appears: Choose the maximum by length subarray (continuous subsegment) consisting only of zeros, among all such segments choose the leftm...
256 megabytes
import java.math.BigInteger; import java.util.*; public class Main { public static void main(final String[] args) { final Scanner in = new Scanner(System.in); int num = in.nextInt(); while (num-- != 0) { int n = in.nextInt(); int[] dt = new int[n+1]; Pri...
Java
["6\n1\n2\n3\n4\n5\n6"]
1 second
["1 \n1 2 \n2 1 3 \n3 1 2 4 \n2 4 1 3 5 \n3 4 1 5 2 6"]
null
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings" ]
25fbe21a449c1ab3eb4bdd95a171d093
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases...
1,600
For each test case, print the answer — the array $$$a$$$ of length $$$n$$$ after performing $$$n$$$ actions described in the problem statement. Note that the answer exists and unique.
standard output
PASSED
3956c0c19c7ec947420409911e062559
train_002.jsonl
1463416500
There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank n are neighbours if n &gt; 1. No bank is a neighbour of itself.Vasya has an account in each bank. Its balance may be negative, meaning ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf675c { public static void main(String[] args) throws IOException { int n = ri(), a[] = ria(n), db[] = new int[n * 2], seg[] = new int[n], ans = n - 1; for (int i = 0; i < n; ++i)...
Java
["3\n5 0 -5", "4\n-1 0 1 0", "4\n1 2 3 -6"]
1 second
["1", "2", "3"]
NoteIn the first sample, Vasya may transfer 5 from the first bank to the third.In the second sample, Vasya may first transfer 1 from the third bank to the second, and then 1 from the second to the first.In the third sample, the following sequence provides the optimal answer: transfer 1 from the first bank to the seco...
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings", "greedy" ]
be12bb8148708f9ad3dc33b83b55eb1e
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of banks. The second line contains n integers ai ( - 109 ≤ ai ≤ 109), the i-th of them is equal to the initial balance of the account in the i-th bank. It's guaranteed that the sum of all ai is equal to 0.
2,100
Print the minimum number of operations required to change balance in each bank to zero.
standard output
PASSED
2de7111787676004c3d59ba8de0bea29
train_002.jsonl
1463416500
There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank n are neighbours if n &gt; 1. No bank is a neighbour of itself.Vasya has an account in each bank. Its balance may be negative, meaning ...
256 megabytes
import java.io.BufferedOutputStream; import java.io.Closeable; import java.io.DataInputStream; import java.io.Flushable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map.E...
Java
["3\n5 0 -5", "4\n-1 0 1 0", "4\n1 2 3 -6"]
1 second
["1", "2", "3"]
NoteIn the first sample, Vasya may transfer 5 from the first bank to the third.In the second sample, Vasya may first transfer 1 from the third bank to the second, and then 1 from the second to the first.In the third sample, the following sequence provides the optimal answer: transfer 1 from the first bank to the seco...
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings", "greedy" ]
be12bb8148708f9ad3dc33b83b55eb1e
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of banks. The second line contains n integers ai ( - 109 ≤ ai ≤ 109), the i-th of them is equal to the initial balance of the account in the i-th bank. It's guaranteed that the sum of all ai is equal to 0.
2,100
Print the minimum number of operations required to change balance in each bank to zero.
standard output
PASSED
96b9c802bec378fe3cd11623a1127565
train_002.jsonl
1463416500
There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank n are neighbours if n &gt; 1. No bank is a neighbour of itself.Vasya has an account in each bank. Its balance may be negative, meaning ...
256 megabytes
import java.io.BufferedOutputStream; import java.io.Closeable; import java.io.DataInputStream; import java.io.Flushable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map.E...
Java
["3\n5 0 -5", "4\n-1 0 1 0", "4\n1 2 3 -6"]
1 second
["1", "2", "3"]
NoteIn the first sample, Vasya may transfer 5 from the first bank to the third.In the second sample, Vasya may first transfer 1 from the third bank to the second, and then 1 from the second to the first.In the third sample, the following sequence provides the optimal answer: transfer 1 from the first bank to the seco...
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings", "greedy" ]
be12bb8148708f9ad3dc33b83b55eb1e
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of banks. The second line contains n integers ai ( - 109 ≤ ai ≤ 109), the i-th of them is equal to the initial balance of the account in the i-th bank. It's guaranteed that the sum of all ai is equal to 0.
2,100
Print the minimum number of operations required to change balance in each bank to zero.
standard output
PASSED
4e24f984ceebe75e71242947ed5dbf34
train_002.jsonl
1463416500
There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank n are neighbours if n &gt; 1. No bank is a neighbour of itself.Vasya has an account in each bank. Its balance may be negative, meaning ...
256 megabytes
import java.io.BufferedOutputStream; import java.io.Closeable; import java.io.DataInputStream; import java.io.Flushable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map.Entry; /** * Built using...
Java
["3\n5 0 -5", "4\n-1 0 1 0", "4\n1 2 3 -6"]
1 second
["1", "2", "3"]
NoteIn the first sample, Vasya may transfer 5 from the first bank to the third.In the second sample, Vasya may first transfer 1 from the third bank to the second, and then 1 from the second to the first.In the third sample, the following sequence provides the optimal answer: transfer 1 from the first bank to the seco...
Java 11
standard input
[ "data structures", "constructive algorithms", "sortings", "greedy" ]
be12bb8148708f9ad3dc33b83b55eb1e
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of banks. The second line contains n integers ai ( - 109 ≤ ai ≤ 109), the i-th of them is equal to the initial balance of the account in the i-th bank. It's guaranteed that the sum of all ai is equal to 0.
2,100
Print the minimum number of operations required to change balance in each bank to zero.
standard output
PASSED
580a877f0797c35d4b9d42532a102267
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.List; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.SortedSet; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.util.TreeSet; import java.util.StringT...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
cc16887fc4aa108b6844822fff2fbec4
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.io.*; import java.util.*; public class CF { FastScanner in; PrintWriter out; class Party implements Comparable<Party> { int from, to; int id; public Party(int from, int to, int id) { super(); this.from = from; this.to = to; this.id = id; } @Override public int compareTo(Party ...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
3647862cdd7c392df7673736feeee915
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import java.util.ArrayList; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.Comparato...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
8bf9ec705fac0f4b3548abe9ae4048d6
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.Arrays; import java.util.TreeSet; import java.util.ArrayList; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Comparator; import java.util.Collections; import ja...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
227424f4a439d79ef01f71a4ac5ab77d
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.io.*; import java.util.*; public class R283qCDistrubtingParts { public static void main(String args[]) { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); boolean yes = true; int n = in.nextInt(); int ans[] = new int[n + 1]; ArrayList<Pair> list =...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
c2db4fafc7314c691a688c9da015df43
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import com.sun.org.apache.xpath.internal.operations.Bool; import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main extends PrintWriter { BufferedReader in; StringTokenizer stok; final Random rand = new Random(31); final int inf = (int) 1e9; final long linf = (long) ...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
89019757131c20e7629f676379a7891f
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.NavigableSet; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.util.ArrayList; import java.util.List; import java.util.NoSuchElementException; import java.math.BigInteger; import java.io.OutputStream; import java.util.Collections; import java.io.PrintWriter; import ja...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
f607fa9896163754aba3284afdea5085
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; /** * @author Pavel Mavrin */ public class C { private void solve() throws IOException { int n = nextInt(); List<Segment> a = new ArrayList<Segment>(); ...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
05aa161e2965d24fe3d45c847b548839
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.Arrays; import java.util.TreeSet; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Comparator; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper ...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
d086a24b4b80294a8cfcced4e97b508e
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeSet; public class C { public static void main(String[] args) throws IOException { init(); int n = nextInt(); ArrayList<Point> points = new ArrayList<>(); ...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
8e6c7467d611ce404b55936f5b700a64
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.*; import java.text.*; import java.io.*; import java.math.*; import java.awt.geom.*; public class Cf496E { public static void main(String[] args) { Distributing_Parts tmp=new Distributing_Parts(); tmp.solve(); } } class Distributing_Parts { static class Singer { int l,r; int cont,id; Sing...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
ec13f6c5a14264f3ce0cb104546eedec
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.io.*; import java.util.*; public class C { FastScanner in; PrintWriter out; class Segment implements Comparable<Segment> { int l, r, k; int id; public Segment(int l, int r, int k, int id) { super(); this.l = l; this.r = r; ...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
02a0641d4724455fd2e226a53eb0d69d
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.TreeSet; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
68b3c46f894f41863f26bf3da59ac739
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.Strin...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
b935311b6b829958b7a2ab003d179dd2
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; /** * Created by dhamada on 15/05/17. */ public class C { public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); ...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
63f9375c9eb460ad00f7aa0299b739c6
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.List; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.ArrayList; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.Collections; import java.io.InputStream; /...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
ac7231cf0fec3c5c2b6abe7b0108279a
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.List; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.SortedSet; import java.util.Set; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.TreeSet; import java.util.StringTokenizer; import ja...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
ba6efb304999cf6328bed82a2657e73c
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
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.SortedSet; import java.util.Set; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; import java.util.StringTokenizer; import jav...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
b6d1887dec2b0f0ad6fa907732fe23f6
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.awt.Point; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.uti...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
ead30c62e4ac813cf992259c4ad87ad7
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.awt.Point; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java....
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
623cd90380a44e9344dcc40943a7d1f0
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.awt.Point; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java....
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
6408d51063844bfb92775c0a5689e1ba
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.io.*; import java.util.*; public class C { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; static class Task implements Comparable<Task> { int l, r, id; public Task(int l, int r, int id) { this.l = l; this.r = r; this.id = id; } @Override public int compareT...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
206ce48f129e7e77fb03da942a9e3651
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.*; import java.io.*; import java.awt.Point; import java.math.BigDecimal; import java.math.BigInteger; import static java.lang.Math.*; // Solution is at the bottom of code public class C implements Runnable{ final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
60a5c138887c0b208ee6e8dbfa21d5e2
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.SortedSet; import java.util.Set; import java.util.Comparator; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.TreeSet; import java.io.InputStream; /** * Buil...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
110c7b278827f2a0b65870f64e0dd324
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.Arrays; import java.util.TreeSet; import java.util.ArrayList; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Collections; import java.io.IOException; import jav...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
29b5ffed25580cce7d2cba76516b0bb0
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.Arrays; import java.util.TreeSet; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Comparator; import java.io.IOException; import java.util.SortedSet; import java.util.Set; import java....
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 8
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
46a69e5c1aeae8fad2c2611eba745e9f
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.TreeMap; public class Main { // public static void main(String[] args) throws ...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 6
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
5dccfbf151e0d932d7e30c42587ad9bc
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.List; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.TreeMap; import java.util.ArrayList; import java.io.PrintStream; import java.io.BufferedReader; import java.util.Comparator; import java.io.OutputStream; import java.io.PrintWriter; import java...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 6
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
f7e8188de3b1eebfdd0370d386804fa4
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.List; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeMap; import java.util.ArrayList; import java.io.PrintStream; import java.io.BufferedReader; import java.util.Comparator; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; im...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 6
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
651f4d51c1c38723d5ad7f7e6f9a4b30
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
/* * * @author Mukesh Singh * */ /* Finding_the_Minimum_Window_in_S_which_Contains_All_Elements_from_T */ import java.io.*; import java.util.*; import java.text.DecimalFormat; @SuppressWarnings("unchecked") public class AB { //solve test cases void solve() throws Exception { LinkedList<PP> ls = new LinkedL...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 6
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
6b888cf682469a9e78d0c2a6f330649e
train_002.jsonl
1418833800
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.First, each actor h...
256 megabytes
import java.util.Arrays; import java.util.TreeSet; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.util.List; import java.math.BigInteger; import java.io.PrintStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Comparator; import jav...
Java
["3\n1 3\n2 4\n3 5\n2\n1 4 2\n2 5 1", "3\n1 3\n2 4\n3 5\n2\n1 3 2\n2 5 1"]
2 seconds
["YES\n1 1 2", "NO"]
null
Java 6
standard input
[ "greedy", "two pointers", "implementation", "sortings", "data structures" ]
7fdcfe1a45994e051345cb6462253ef7
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105). Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109). The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105). Next m lines contain t...
2,100
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line. In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of t...
standard output
PASSED
271c56be7b348288d1c0f744a61dfd5c
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.util.*; import java.io.*; public class d3 { public static int[] str; public static int n; public static IntervalTree it1, it2; public static void main(String[] Args) { Scanner sc = new Scanner(System.in); String s = sc.next(); n = s.length(); s...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
53b988172f3d1fda51e8e0ff1d658951
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.PriorityQueue; public class LeastCostBracketSequence { // A class to keep track of the closing brackets placed, // in case they need to be switched. It will be used in // a priority queue based on the dif...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
613838cae8c194c22aadf5a26bd319cc
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collection; import java.util.PriorityQueue; import java.util.StringTokenizer; import java.util.stream.Stream; public class Main implements Runnable { stat...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
3484b3010c7d334e459fbf0368acafd6
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.PriorityQueue; public class Main { public static class Paren implements Comparable<Paren> { int cost; int index; public Paren(int c, int i) { cost = c; index = i; } @Overri...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
ba0eb23313638c0153fdbd03e9da861f
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.util.*; import java.io.*; public class leastCost { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringBuilder pattern = new StringBuilder(in.readLine()); long cost...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
b46323ed3afd824ad451671d3583efcc
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
//package main; import java.io.*; import java.util.*; public class Main{ public static void main(String[] args) throws IOException { Reader.init(System.in); StringBuffer outBuffer = new StringBuffer(); //TODO: implement brute force? (O(n^2), n = 5*10^4) //BaseCost...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
cc89432212d7a7787fe60aac6bd23098
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.util.*; import java.io.*; public class Main { // We'll need some sort of structure to hold the cost for each parenthesis static class Paren implements Comparable<Paren> { int index, cost; Paren(int c, int i) { this.index = i; this.cost = c; } @Override public int compareTo(Paren par...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
098f2d211e5357562cbafcd5ec3ca6bc
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.PriorityQueue; import java.util.StringTokenizer; public class E { public static void main(String[] args) throws IOExcepti...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
0769e8b112418961fbb27fb5e93120fa
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.PriorityQueue; import java.util.StringTokenizer; public class Problem3D { private static class CostDiff implements Comparable<CostDiff> { int diff; int pos; CostDiff(int diff, int pos) { this.diff ...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
b1ad27959f09989b07546e618f126e40
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; /** * Created by James on 1/29/2015. */ public class Driver { public static void main(String [] args) throws IOException { BufferedReader scanner = new BufferedReader(new InputStreamReader(Sys...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
c4f80fcd0d3aba8382ac183bcb3bb2d6
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.*; import java.util.*; public class D0003_LeastCostBacketSequence { static class Bracket implements Comparable<Bracket> { int index; int open; int close; public Bracket(int i, int o, int c) { index = i; open = o; close = c; } public int compareTo(Bracket b) { return Integ...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
c62a9e937fa8139b9da6eeeb7b950ef0
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.PriorityQueue; public class Main { public static class Paren implements Comparable<Paren> { int cost; ...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
151d97948d09c281fe7275203c0a34b7
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.PriorityQueue; import java.util.Queue; public class A3D { ...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
1bf04ca81317c39fc0f0b4fbb69ad006
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.PriorityQueue; import java.util.Comparator; import java.io.IOException; public class Main { static class Pair { private int first; private int second; public Pair(int f...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
9ebae58394477e3a46699160619e67d9
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
//package CF; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.PriorityQueue; import java.util.StringTokenizer; public class D { public static void main(String[] args) t...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
bb529d082fde11cac92369f774a6908d
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.*; import java.util.*; public class Xyz { public static void main(String [] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); if (s.length() % 2 == 1) { System.out.println(-1); ...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
995569c0c316d66370f1156c0eb2746f
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.util.*; import java.io.*; public class Solution { public static PrintWriter w = new PrintWriter(System.out); public static long tc = 0; public static long INF = 1000000000000L; public static void main(String args[] ) throws Exception { Reader in = new Reader(); char[] arr = in.next().toCharArray();...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
0d29f1a072608559ec678ef1e0b4104b
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.PriorityQueue; import java.util.Queue; /** * Created by harish.sharma on 10/9/16. */ public class A1 { public static void main(String[] arg) throws IOException { BufferedReader br = new Buffered...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
4237c21480016d5c055cd898e727aa2b
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.PriorityQueue; import java.util.Queue; public class LeastCostBracket { public st...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
27760e5275501181e4deabc470fea8d6
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.*; import java.util.*; public class Driver { public static class Cost implements Comparable<Cost> { int cost; int pos; Cost (int c, int p) { this.cost = c; this.pos = p; } public int compareTo(Cost c) { if (this.cost > c.cost) { return 1; } else { return -1; } ...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
70ec79efea1c0c862fae7c00dd11b9b7
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.PriorityQueue; import java.util.StringTokenizer; public class Main { static class mark implements Comparable<mark> { long a; long b; int idx; long...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
be16a4d74546689758f6821de266719a
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
// Don't place your source in a package import java.util.*; import java.lang.*; import java.io.*; import java.math.*; // Please name your class Main public class Main { static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static int read() throws IO...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
6a0f240dbda17bb9ba62a5a44d51a758
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.*; import java.util.*; public class CF3D { static class P implements Comparable<P> { int cost, i; P (int cost, int i) { this.cost = cost; this.i = i; } @Override public int compareTo(P p) { return this.cost - p.cost; } } public static void main(String[] args) throws IOException {...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
a98a1b31f42b27f2c644cdcd6664e1c8
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.util.*; /** * Created by huang on 17-6-10. */ public class Main { private static class cost { int a, b; public cost(int a, int b) { this.a = a; this.b = b; } } public static void main(String[] args) { Scanner in = new Scanner(System.i...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
4d5656a294ccf9ccca52c8725d26faf8
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.PriorityQueue; import java.util.StringTokenizer; public class CF3D { static class Pair implements Comparable<Pair> { int i...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
939125ea719e7e2502b6badd24b34503
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.*; import java.util.*; public class CF3D_brackets { public static class cost implements Comparable<cost> { int cost; int index; cost(int c, int i) { this.cost=c; this.index=i; } public int co...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
7212de80f31e7fc11a45ff7ce147fc1a
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.PriorityQueue; import java.util.StringTokenizer; import java.util.TreeMap; public class D3 { public static void main(String[] args) throws IOException { Scanner in = new Scann...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
8c1edffb60d52301d93214bbaf890a01
train_002.jsonl
1267963200
This is yet another problem on regular bracket sequences.A bracket sequence is called regular, if by inserting "+" and "1" into it we get a correct mathematical expression. For example, sequences "(())()", "()" and "(()(()))" are regular, while ")(", "(()" and "(()))(" are not. You have a pattern of a bracket sequence ...
64 megabytes
import java.util.PriorityQueue; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class Main { public static void main(String[] args) throws IOException { BufferedReader scan = new BufferedReader(new InputStreamReader( System.in)); char[] word = scan.readLine...
Java
["(??)\n1 2\n2 8"]
1 second
["4\n()()"]
null
Java 8
standard input
[ "greedy" ]
970cd8ce0cf7214b7f2be337990557c9
The first line contains a non-empty pattern of even length, consisting of characters "(", ")" and "?". Its length doesn't exceed 5·104. Then there follow m lines, where m is the number of characters "?" in the pattern. Each line contains two integer numbers ai and bi (1 ≤ ai,  bi ≤ 106), where ai is the cost of replaci...
2,600
Print the cost of the optimal regular bracket sequence in the first line, and the required sequence in the second. Print -1, if there is no answer. If the answer is not unique, print any of them.
standard output
PASSED
4014a9f79d7536f731c092a74f5dd1ea
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class D im...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
4af4a4eebd4a750a0cf3351fc9e693c8
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class D { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader in = new Buf...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
87dc1b202bc2fbfe7af6c4917671ad63
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Scanner; import java.util.StringTokenizer; public class D { static HashMap<Integer, Integer> upMap = new HashMap<Integer, Integer>(); public static void main(String[] args) ...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
aee786c9851b98cac259135b98e8689b
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.util.*; import java.io.File; import java.io.PrintWriter; import java.math.*; import static java.lang.Character.isDigit; import static java.lang.Character.isLowerCase; import static java.lang.Character.isUpperCase; import static java.lang.Math.*; import static java.math.BigInteger.*; import static java.util...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
1a9263773c7900051268dbda2779fb2c
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Locale; import java.util.StringTokenizer; public class D implements Runnable { int[] line; void setEl(int key...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
9f044be7e86b57ed36d592d1af07eefb
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.*; import java.util.*; public class D{ void solve()throws Exception { int n=nextInt(); int[]x=new int[n]; int[]y=new int[n]; for(int i=0;i<n;i++) { x[i]=nextInt()-1; } for(int i=0;i<n;i++) { y[i]=nextInt...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
40409bfeb3c7fe59bc9c23cfc6ec7404
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
6ab9c272f80de7ec84e4affa6602efde
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static int L = 0; public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
24b46bd905c948e464d8928d3b05d76a
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import static java.lang.Math.*; import static java.lang.System.currentTimeMillis; import static java.lang.System.exit; import static java.lang.System.arraycopy; import static java.util.Arrays.sort; import static java.util.Arrays.binarySearch; import static java.util.Arrays.fill; import java.util.*; import java.io.*; p...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
f4842683d58bb6388949f00ece673614
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.List; /** * @author Egor Kulikov (egor@egork.net) */ public class TaskD { @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) private final InputRead...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
aaa0f05e0bbb77fdcb2e8cf7a1ddd47b
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
/* * Hello! You are trying to hack my solution, are you? =) * Don't be afraid of the size, it's just a dump of useful methods like gcd, or n-th Fib number. * And I'm just too lazy to create a new .java for every task. * And if you were successful to hack my solution, please, send me this test as a message or to Abr...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
fb21d5dd111d96995d20d1389e053c71
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class D { private final boolean useStandardIO = true; private final String inFile = "d.in"; private final String outFile = "d.out"; private void solve() throws IOException { int n = nextInt(); int[] a = new int[n]; int[] b = new int[n]; int[...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
d3c683be221f9412a7ee1f0a49630470
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main implements Runnable { final String filename="test"; final int base = 1<<20; int[] tree = new int[base*2]; void set(int x, int val) { x+=base; while (x>0) { tree[x] = Math.max(tree[x], val); x /=2; } } int getmax(int...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
79272f4dce68db761aef4f6ad2a38640
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.Locale; import java.util.StringTokenizer; @SuppressWarnings("un...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
81be9eb2f6e2967af054cd8d7bcec11b
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.*; import java.util.*; public class Main { // static Scanner in; static PrintWriter out; static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;} static int[] max; static void add(int i, int val) { if (i == 0) return; max[i] = Math.max(max[i], val);...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
5e73ac5f7a8e806bad046a454cb88e23
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { static final int INF = (int) 1e9; int decSeq(int[] arr) { int n = arr.length; int [] din = new int[n + 1]; Arrays.fill(din, -INF); for (int i = 0; i < n; ++i) { int l = -1; int r = din.length; //[) while(r - l > 1) { i...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
4bb5725cb70b7a9f07149336900accd0
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import javax.print.attribute.standard.Finishings; public class CodeE { static class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(Syste...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
72bd52f0c2637acd955f98e913383e12
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.*; import java.util.*; public class Solution { private BufferedReader in; private PrintWriter out; private StringTokenizer st; void solve() throws IOException { int n = nextInt(); if (n == 0) { throw new AssertionError(); } int[] a = new int[n]; Arrays.fill(a, -1); int[] le = new i...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
03135634826cfa656e3c7fb1bb6d6ac4
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.Arrays; public class D61 { static StreamTokenizer in; static PrintWriter out; static int nextInt() throws IOException { in....
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
e5ca72c20a9e6a78c95cef56ef6bfc68
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class OpticalExperiment { public static void update(int i, int val, int[] bit) { while (i < bit.length) { if (val > bit[i]) ...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
1aff99e62dcd48bdc7eb213de4ddbc82
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; public class D { public static int LIS(int[] x) { int n = x.length; int[] L = new int[n + 1]; Arrays.fill(L, Integer.MAX_VALUE); int max =...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
d8e425e5905ad8439d65d64f91c1fffb
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.*; import java.util.*; public class D { int n; int[] x, y; int[] a; private void solve() throws IOException { n = nextInt(); x = new int[n]; y = new int[n]; for (int i = 0; i < n; i++) { x[i] = nextInt() - 1; } int[] start = new int[n]; for (int i = 0; i < n; i++) { start[x[i]]...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
58beb60d6ec81e97023b72e49dec30ff
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.awt.*; public class D { MyScanner in; PrintWriter out; public static void main(String[] args) throws Exception { new D().run(); } public void run() throws Exception { in = new MyScanner(); out = new Pri...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
2027eb69a417ba006c8908b6b9d9de31
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.Locale; import java.util.StringTokenizer; public class D implements Runnable { BufferedReader in; StringTokenizer st = new StringTokenizer(""); PrintWriter out; public void solve() throws IOException { int n = nextInt(); int[] x = ne...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
66b2ab2b929911d3a30bd7d05218be09
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Random; import java.io.Writer; import java.util.AbstractCollection; import java.io.IOException; import java.io.InputStreamReader; import java.util.Ar...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
b9b55d59d37b0b6f4b4336c69f2e919b
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.TreeMap; import java.util.InputMismatchException; import java.util.ArrayList; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Random; import java.util.TreeSet...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
2be1d4f44d85abb61e0c3253e77b8350
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.TreeMap; import java.util.InputMismatchException; import java.util.ArrayList; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Random; import java.util.TreeSet...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output
PASSED
3d5601065ac0f49b3fdf2dc08fcabc56
train_002.jsonl
1300033800
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each h...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.ArrayList; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Random; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper plug-in * A...
Java
["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1"]
5 seconds
["3", "2"]
NoteFor the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersect...
Java 6
standard input
[ "dp", "binary search", "data structures" ]
b0ef9cda01a01cad22e7f4c49e74e85c
The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-t...
1,900
Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.
standard output