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
f41fd365cac1aa9ae0681f51743b5467
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.util.Scanner; public class A { /** * @param args * @throws IOException */ public static void main(String[] args) { // TODO Auto-generated method stub @SuppressWarnings("resource") Scanner in = new Scanner(System.in); int n = in.nextInt(); char[] c = new char[n]; String line = in.ne...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
27f84ee5812a3f0eaf93141d76dffb73
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class A { public static void main(String[] args) throws IOException { PrintWriter out = new PrintWriter(System.out); BufferedReader br = new BufferedReader(new Input...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
e7d330eed09f9c63525f114230d43dfa
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
//package n180; import java.util.Scanner; public class Snow { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int n = s.nextInt(); String str = s.next(); // System.out.println(str); s.close(); int start = 0, end = 0; for (int i = 0; i < ...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
65cbac3b64c9ef9b7507fd72fda1979f
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.util.Scanner; public class AA { public static void main(String[] args) { Scanner in =new Scanner (System.in); String a=""; int e=0; int num=in.nextInt(); int s=0,t=0; a=in.next(); for(int i=0;i<num;i++){ if(a.charAt(i)=='R'){ e=1; break; ...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
b6b8786884c1327e46231438e81bfcf2
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.*; import java.util.*; /** * * @coder Altynbek Nurgaziyev */ public class C298A { void solution() throws Exception { int n = in.nextInt(); String s = "." + in.next() + "."; ArrayList<Integer> list = new ArrayList<>(); for (int ...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
10c9d3db790d6c86f443cb1c7470ec98
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; public class A { public static BufferedReader in; public static PrintWriter out; public static void main(String[] args) throws IOException { in = new BufferedReader(ne...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
9f525d76b43edeb785632adb7c74fcad
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class SnowFootprints { public static void main(String [] args) throws IOException { BufferedReader br = new BufferedReader(new InputStre...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
968c4b18567e9f9c086e3d58773cd6dd
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner myScanner = new Scanner(System.in); myScanner.nextInt(); String s = myScanner.next(); if (s.matches(".+R+L+.+")) { System.out.println((s.indexOf('R') + 1) + " " ...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
d689458f967dd6250274f1048c32fafa
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.StreamTokenizer; //You can include standard Java language libraries that you want use.// import java.util.*; public class Task{ /* public static Stre...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
8153986a01234638644d90832f6a0af4
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); bf.readLine(); String road = bf.readLine();...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
a95dd60ac7ec0e9bcf5afbbe42ad9808
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); bf.readLine(); String road = bf.readLin...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
e339923b69b3fa6a688218007a92337b
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); bf.readLine(); String road = bf.readLi...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
7f92caacd2e1707d302e214cd65aa0bf
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); bf.readLine(); String road = bf.readLine()...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
ecaf8319ef0c371855ede7a3cd884f8c
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); bf.readLine(); String road = bf.readLine(...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
1256e6e6a92a31d372167ebf8a2b59d3
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); bf.readLine(); String road = bf.readLine...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
597f20b40f0ea0990f8222f9762c0483
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanIn = new Scanner(System.in); int s,t; int n = Integer.valueOf(scanIn.nextLine()); char[] prints = scanIn.nextLine().toCharArray(); // System.out.println(n); // for (c...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
9606af093fbf31cd8dfc2ecfa398c7ef
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.IOException; import java.util.Scanner; public class Main { public static String helper(String s){ String res = s.indexOf("L")!=-1 ? (s.lastIndexOf("L")+1)+" "+(s.indexOf("L")):(s.indexOf("R")+1)+" "+(s.lastIndexOf("R")+2); return res; } public sta...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
f18992c857879b78713ad5430727a1de
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.StringTokenizer; import java.util.TreeMap; import ...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
337e0f3cf5a1b9b0a01bc389e5814f0c
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
//package round180_div2; import java.util.Scanner; public class ProblemA { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int s = 0; int t = 0; sc.nextLine(); char[] road = sc.nextLine().toCharArray(); int i = 0; int countR = 0; int countL = 0; ...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
571fb1f8f8e0734a5264559f6a0cf13a
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader Bf = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(Bf.readLine()); String s = Bf.readLine(); int start = 0; int flag = 0; int x = 0; for ...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
9b7fd640f6cf57e3ffeb4a116683fcfc
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Vaibhav Mittal */ public class Main { public static void main(String[] args) { Inp...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
46a6cb47206ca917cab114324c0ce27b
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.math.BigInteger; import java.util.Arrays; import java.util.Scanner; ///Dude public class Main { public void snowprints(int size,String path) { int s=0; int t=0; int r=path.indexOf("R"); ...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
7a3636893a10c8099338b02e88e520ac
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.*; public class snow { public static void main(String args[])throws Exception { BufferedReader e=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(e.readLine()); String a=e.readLine(); int d=0,r=0,l=0,i; for(i=0;i<n;i++) { if(a.charAt(i)=='R') r++; if(a.charAt(i)=='L') l++; } f...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
1d4ee6db0e820416e03ece5ad9187b95
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String args[]) throws IOException { Reader.init(System.in); int l=0, r=0; int n=Reader.nextInt(); String s=Reader.next(); System.out.println((!s.contains("L"))?(s...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
0cc0e6bc8d81d74f46f1d63b6b865c84
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.util.*; public class SnowFootprints{ public static void main(String[] Args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String s = sc.next(); boolean hasR = false; boolean hasL = false; int lastR = -1; int firstL = 1001; for(int k = 0; k < s...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
c4012b8f00193610d15bafd6f041de5e
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * ..RRLL... 123456789 ......>>o ..RRLL... ......o<< --------------------- 11 .RRRLLLLL.. 12345678901 ....>>>o... ..o<<<<<... --------------------- * * ---------------- LLLLRRRRRRR .RRRLLLLL.. 12345678901 ......o.......
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
221766ae60eca946b167f7bb5ffcb62d
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br1 = new BufferedReader( new InputStreamReader(System.in)); int n = Integer.parseInt(br1.readLine()); String data = br...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
f608c9c06731283b4422df71a78e1304
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.util.Scanner; public class Snow { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] road = new char[n]; String str = sc.next(); for(int k=0;k<n;k++) road[k] = str.charAt(k); int Rleft=1,Rright=n,Lleft=1,Lright=n; for(int i=0;i<n;...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
6f0217ae64a2d90891b208f62689ee22
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @auth...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
d265ea4b59b9fdc108e7bdeb85da694a
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.IOException; import java.util.InputMismatchException; public class SnowFootprints { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); sc.nextInt(); String S = sc.nextString(); int firstR = S.indexOf('R'); if (fi...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
b47331465a66941e50cabc61a0f9bc34
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.util.*; public class Main{ static String test1 = "9\n..RRLL..."; static String test2 = "11\n.RRRLLLLL.."; static String test3 = "3\n.R."; static String test4 = "3\n.L."; public static void main(String[] args){ Scanner in = new Scanner(System.in); String prints = in.nextLine();//numbereater prints...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
168aac9a8bbef11e4356ca96342e082e
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class SnowFootprints { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); ...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
16410c15aeebb2090d8d220429b76f31
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class SnoFootprints { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); ...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
0718ef38e96e4a3d85d4a0aad0e03012
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class my_class { public static void main(String[] args) { Scanner ololo = new Scanner(System.in); int n = ololo.nextInt(), s, t; ololo.nextLine(); String str = ololo.nextLine(); if(!str.contains("R")){ System.out.pri...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
0a3484fefc10b98177f9c2e6c73bc09d
train_002.jsonl
1366385400
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ...
256 megabytes
import java.util.*; import java.io.*; public class A180 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); sc.nextLine(); String foot = sc.nextLine(); sc.close(); int start = -1; int end = -1; ...
Java
["9\n..RRLL...", "11\n.RRRLLLLL.."]
1 second
["3 4", "7 5"]
NoteThe first test sample is the one in the picture.
Java 7
standard input
[ "implementation", "greedy" ]
3053cba2426ebd113fcd70a9b026dad0
The first line of the input contains integer n (3 ≀ n ≀ 1000). The second line contains the description of the road β€” the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint). It's guaranteed tha...
1,300
Print two space-separated integers β€” the values of s and t. If there are several possible solutions you can print any of them.
standard output
PASSED
32f8be140b3e609d8f2f8eea8570d0c6
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.*; import java.util.ArrayDeque; import java.util.StringTokenizer; public class Main { public static Reader in = new Reader(); public static Writer out = new Writer(); public static void main(String[] args) { char[] c = in.readLine().toCharArray(); final int N = c.length; int[] len = ne...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
a207867c78af50bce95fbbc43871590c
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.IOException; import java.io.*; import java.util.Stack; import java.util.StringTokenizer; /** * * @author shnovruzov */ public class Main{ public void solve() throws IOException { String s; Stack<Integer> stack = new Stack(); s = in.readLine(); int dp[] = new int[s...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
233faf3b8b73a16687ad9a17405a2310
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.BufferedInputStream; import java.util.Scanner; import java.util.Stack; /** * User: SDU_Phonism * Flag: String problem * Date: 12-12-4 */ public class cf5C { public static void main(String ags[]) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); char[] v= cin.next()...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
1379ea0b1a9f07255c0b452497586803
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.*; import java.util.ArrayDeque; import java.util.Deque; import java.util.StringTokenizer; /** * CodeForces Round 5C. Longest Regular Bracket Sequence * Created by Darren on 14-9-14. */ public class Main { Reader in = new Reader(System.in); PrintWriter out = new PrintWriter(System.out); ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
fde01caf19f816c3eeb12ff7048ce533
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; public class LongBracket { public static void main(String[] args) throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); char[]brackets = in...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
057ddc30e16c4db7e7d0eb51a9dc5167
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; public class C { static BufferedReader in = new BufferedReader(new InputStreamReader( System.in)); public static void main(String[] args) throws IOException { String s = ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
f0c828c0a4cbb9354454895af1479a21
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Stack; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
e0891d9e9bbcac09351467de2fca60cc
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arra...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
952b585ae22bbfd108ebb8285668e0bb
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.*; import java.util.*; public class CF5C { public static void main(String[] args){ Scanner br = new Scanner(System.in); String line = br.next(); Stack<Integer> st = new Stack<Integer>(); Stack<Integer> ends = new Stack<Integer>(); int max = 0; int count = 1; for(int i = 0;i<line.length();i...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
7cc1629cc4e7d265d09cad4a7328be74
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.Scanner; import java.util.Stack; public class BracketSeq { public static void main(String[] args){ Scanner s = new Scanner(System.in); int[] maxStrLength = new int[1000005]; String string = s.nextLine(); int longestSub = 0; int subCount = 1; ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
735d0d5a89be0bf477eb4b4c0f5ea8fe
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.*; public class LongestBracketSequence { public static void main(String[] args) { String input = ""; int temp = 0; int ans = 0; int count = 1; int max = 0; int x = 0; try { BufferedReader br = new BufferedReader(new Inpu...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
c9cb0f9957c05fa618723fc8b522185f
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; import java.math.BigInteger; import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; public class Main { static StringTokenizer st=new StringTokenizer(""); static BufferedReader br; /////////////////////////////...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
bbdb7581ddd7b9df17fc3f79c2b3b7f1
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.*; public class Bracket { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.next(); int[] counts = new int[s.length()+1]; counts[0] = 0; int startingIdx = 0; int bestLen = 0; int bestCount = 1; ArrayDeque<Integer> stack = new ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
002077e80b7a041250063c83cec3a192
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args){ Scanner scan = new Scanner(System.in); char[] l1 = scan.next().toCharArray(); ArrayList<Integer> last = new ArrayList<>(); char[] ok = new char[l1.length]; for (int i = 0 ; i < l1.length; i++){ ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
a55de81ed675195f56d86791bdaa8ba7
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.*; import java.io.*; public class Main implements Runnable { public void solve() throws IOException { char[] c = nextToken().toCharArray(); ArrayDeque<Integer> stack = new ArrayDeque<>(); stack.add(0); //the first illegal position ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
7598b7b3f6be22b9d585ba36fddba88d
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.*; import java.util.*; public class LongBracketSequence { public static void main(String args[])throws IOException { BufferedReader reader=new BufferedReader(new InputStreamReader(System.in)); //BufferedReader reader=new BufferedReader(new FileReader("bracket")); ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
1bb161924cd6d5350e82597a732a302b
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.*; import java.util.*; public class LongBracketSequence { public static void main(String args[])throws IOException { BufferedReader reader=new BufferedReader(new InputStreamReader(System.in)); //BufferedReader reader=new BufferedReader(new FileReader("bracket")); ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
3da13ee3e97395e23acc5d89fa4af1a9
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Stack; public class R5qCLongestRegularBracketSequence { public static void main(String args[] ) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Prin...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
82181d131ebabdf71733763570d1493b
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.Arrays; import java.util.Scanner; import java.util.Stack; /** * * @author 753617 */ public class Bseq { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner in = new Scanner(System.in); String i=" "+in.nextLine(); boolean b[] ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
674a8de0d0532d3995481bd219174563
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); Stack<Integer> stack = new Stack<Integer>(); Set<Integer> set= new HashSet<Integer>(); String s=in.next(); int len = s.length(),i; int length=0,max=0,num=0; boolean Fl...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
5641b167df42ef7bf9ab6ec1dbd3c784
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.*; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.nextLine(); int cishu = 1; int length = 0; int temp = 0; int cunzai = 0; int flag[] = new int[10000]; int cnt = 0; int stack[] = new...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
b7d357301d30ce46352d133bfdab645b
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.*; import java.io.*; public class C0005 { public static void main(String args[]) throws Exception { new C0005(); } C0005() throws Exception { PandaScanner sc = null; PrintWriter out = null; try { sc = new PandaScanner(System.in); ou...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
c5732b266ea031a2d2bcf292bfdcee76
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.Scanner; import java.util.Stack; public class CF5C { private static int[] solve(String sequence) { int maxLen = 0, sum = 1; int[] len = new int[sequence.length()]; Stack<Integer> bracket = new Stack<Integer>(); for(int i = 0; i < sequence.length(); i++) { if(sequence.charAt(i) == '(') { ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
d33a5bc3892ebd4849dcb681dcffa252
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.Scanner; import java.util.TreeMap; public class CF5C { private static int[] solve(String sequence) { int maxLen = 0, sum = 1, balance = 0; TreeMap<Integer, Integer> loc = new TreeMap<Integer, Integer>(); for(int i = 0; i < sequence.length(); i++) { if(sequence.charAt(i) == '(') { balance...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
a490d14c74247057b7daac710037da42
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.Scanner; import java.util.Stack; public class CF5C { static class Bracket { int level, loc; Bracket(int lvl, int l) { level = lvl; loc = l; } } private static int[] solve(String sequence) { int maxLen = 0, sum = 1, balance = 0; Stack<Bracket> bracket = new Stack<Bracket>(); f...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
7b45def4c33cf03ffa04a555399d5a98
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.*; public class Problem5C { public static int[] dp1 = new int[1000001]; public static int[] dp2 = new int[1000001]; public static boolean[] done = new boolean[1000001]; public static void main (String [] args) { Scanner in = new Scanner(System.in); String seq = in.n...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
3c02bb233b0295ce36068b804315bc9b
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Stack; public class LongestBrackets { static class Pair{ int index; char type; public Pair(int index,char type) { this.index = index; this.type = type; } } public static void main(String[]args)throws Throwable {...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
86cef246656ec2bde283de6fa1851f69
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.*; public class TaskC { public static void main(String[] args) { Scanner in = new Scanner(System.in); String st; Stack<Integer> S = new Stack<Integer>(); int N, i; st = in.nextLine(); N = st.length(); st = " " + st; int[] F = new int[N + 1]; for (i = 1; i <= N; ++i) { if (s...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
da18b6125f7a8a14cdaf8e53bf33fe0a
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.*; import java.io.*; public class Main { static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); static StringBuilder out = new StringBuilder(); public static void main(String[] args){ String str = nextLine(); boolean[] brack = new boolean[str.l...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
331fe603878e0f1782b8c4b28e7bbc37
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.*; import java.io.*; public class LongestRegularBracketSequence { public static void main(String[] args) throws IOException { FastScanner in = new FastScanner(); String sequence = in.next(); boolean[] invalid = new boolean[sequence.length()]; int depth = 0; for(int x = 0; x < sequenc...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
7a3ac2daf9e46d92fda5ef7203d0b2c7
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.util.Scanner; import java.util.Stack; public class C5 { private String ip; private int[] ipArr; private int longest; private int occurences = 1; public static void main(String[] args) { C5 obj = new C5(); obj.init(); obj.compute(); } private void init() { Scanner scn = new Scanner(Syste...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
2c77b2998d5b45ba2b7d11bc875d3cb3
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.Closeable; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.Collection; import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.Iterator; import java.util.ArrayDeque; import java...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
918e73799c791ba8a97bc688c2cf66db
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
import java.io.ObjectInputStream; import java.io.Serializable; import java.io.Closeable; import java.io.BufferedReader; import java.io.OutputStream; import java.util.ConcurrentModificationException; import java.io.PrintWriter; import java.io.Writer; import java.io.InputStreamReader; import java.io.IOException; import j...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
af568bd367a35231a3f8be958277bf59
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
//<editor-fold defaultstate="collapsed" desc="comment"> import java.io.File; import java.io.PrintStream; import java.lang.reflect.Array; import java.util.Arrays; import java.util.Scanner; import java.util.Stack; import javax.swing.text.html.HTMLDocument.HTMLReader.PreAction; //</editor-fold> public class Main { ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
5fcbb78d46be495a6cf257c91a157cd7
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
//<editor-fold defaultstate="collapsed" desc="comment"> import java.io.File; import java.io.PrintStream; import java.util.Arrays; import java.util.Scanner; import java.util.Stack; //</editor-fold> public class Main { public static void main(String[] args) throws Exception { StringBuilder resBuilder = ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
7244ff9544ea3d0570e0db178337ae0f
train_002.jsonl
1269100800
This is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting Β«+Β» and Β«1Β» into it we can get a correct mathematical expression. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not. Y...
256 megabytes
//<editor-fold defaultstate="collapsed" desc="comment"> import java.io.File; import java.io.PrintStream; import java.lang.reflect.Array; import java.util.Arrays; import java.util.Scanner; import java.util.Stack; import javax.swing.text.html.HTMLDocument.HTMLReader.PreAction; //</editor-fold> public class Main { ...
Java
[")((())))(()())", "))("]
2 seconds
["6 2", "0 1"]
null
Java 7
standard input
[ "dp", "greedy", "constructive algorithms", "sortings", "data structures", "strings" ]
91c3af92731cd7d406674598c0dcbbbc
The first line of the input file contains a non-empty string, consisting of Β«(Β» and Β«)Β» characters. Its length does not exceed 106.
1,900
Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".
standard output
PASSED
a810041901c8bf09775ec0074da7714c
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class geek1 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.i...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
54d43a74d055d4c08af025c0cca401de
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.util.*; public class gfdgf { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); ArrayList<Integer> arr=new ArrayList<Integer>(); long count=0; int sum=0; int add=0; for(int i=0;i<n;i++) { int a=sc.nextInt(); int b=sc.nextInt(); a...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
d0b1a994e0484352ef41007241c3de33
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
//package contest_488; //import javafx.util.Pair; import java.io.*; import java.util.*; //import contest_488.InputReader.SpaceCharFilter; public class q2 { class Node implements Comparable<Node> { long a; long b; public Node(long a, long b) { this.a = a; this.b = b;...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
8ab55d35c8706f1cabaa56deaa01b70d
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
//package contest_488; //import javafx.util.Pair; import java.io.*; import java.util.*; //import contest_488.InputReader.SpaceCharFilter; public class q2 { public static void main(String[] args) { InputReader in =new InputReader(System.in); OutputWriter out=new OutputWriter(System.out); int n=in.readInt(); int...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
dd2b2643e9ea3c9aeb940a0fb2f5e9f3
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class vew { public static void main(String args[]) { Scanner scan=new Scanner(System.in); long n=scan.nextInt(); long space=scan.nextInt(); pair songs[]=new pair[(int)n]; long sum=0; long com=0; fo...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
a5e865fd4259ed5927fc5473dcf41bd2
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
//package math_codet; import java.io.*; import java.util.*; /****************************************** * AUTHOR: AMAN KUMAR SINGH * * INSTITUITION: KALYANI GOVERNMENT ENGINEERING COLLEGE * ******************************************/ public class lets_do { InputReader in; PrintWriter o...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
20ddf066ce248b7491d89f8c98210e18
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
//package math_codet; import java.io.*; import java.util.*; /****************************************** * AUTHOR: AMAN KUMAR SINGH * * INSTITUITION: KALYANI GOVERNMENT ENGINEERING COLLEGE * ******************************************/ public class lets_do { InputReader in; PrintWriter o...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
23bf3e3c1d163a49f3f79da7a6913455
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; /** * * @author thachlp */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { /...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
f08746d754fbf7a52ef464b54ce795eb
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.util.*; import java.util.Map.Entry; import java.util.regex.Pattern; import java.io.*; import java.math.BigInteger; public class MainClass { public static void main(String[] args) { FastReader in = new FastReader(); int n = in.nextInt(), m = in.nextInt(); pair p[] = new pair[n]; ...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
8c7d1b7f58af8d0c562b8994f7a7aab7
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.io.*; import java.util.*; import java.util.regex.*; public class vk18 { public static void main(String[]stp) throws Exception { Scanner scan=new Scanner(System.in); //BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //String []s; int n=scan.nextI...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
f96e32653f7b1f5ee74a8e50dc97c1e2
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.io.*; import java.util.*; public class d { public static void main(String args[]) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader sc = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStre...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
c98323431bf8221ee273e11ad1f9f41b
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.io.*; import java.util.*; public class d { public static void main(String args[]) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader sc = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStre...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
a416835a658d3225ff96129fc44bb780
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.io.*; import java.util.*; public class d { public static void main(String args[]) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader sc = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStre...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
18644ab420155827d22269c2ec83a3b7
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class zzz_1015C { public static void main(String[] args) { FastReader s = new FastReader(); int n = s.nextInt(); long m = s.nextInt(); long[] diff ...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
e5d31c8ddf13963cfa2366f4bd73e1fe
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class a_1015C { public static void main(String[] args) { FastReader s = new FastReader(); int n = s.nextInt(); long m = s.nextInt(); long[] diff = ...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
c4286962825fbce40ab2ba62fee97df6
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.util.Scanner; public class Main { static int[] array; static int[] tempMergArr; static int length; static void mySort(int inputArr[]) { array = inputArr; length = inputArr.length; tempMergArr = new int[length]; doMergeSort(0, length - 1); } static ...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
191d2d4a70eab307145a6261fab57019
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFilt...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
75d0777c9c10b77a96df34258f3dbc15
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
public class Main { private static void solve() { int n = ni(); long m = ni(); int[] x = new int[n]; for (int i = 0; i < n; i ++) { int a = ni(); int b = ni(); m -= b; x[i] = a - b; } if (m < 0) { System.out.println(-1); return; } radixSort(x...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
69389330e65171a895faca7a45cb92eb
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
public class Main { private static void solve() { int n = ni(); long m = ni(); int[] x = new int[n]; for (int i = 0; i < n; i ++) { int a = ni(); int b = ni(); m -= b; x[i] = a - b; } if (m < 0) { System.out.println(-1); return; } radixSort(x...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
2df76fde6e450a5c00f82a9aeeaec800
train_002.jsonl
1533047700
Ivan has $$$n$$$ songs on his phone. The size of the $$$i$$$-th song is $$$a_i$$$ bytes. Ivan also has a flash drive which can hold at most $$$m$$$ bytes in total. Initially, his flash drive is empty.Ivan wants to copy all $$$n$$$ songs to the flash drive. He can compress the songs. If he compresses the $$$i$$$-th song...
256 megabytes
import java.util.*; public class A_B_and_team_trainin{ public static void main(String[] args) { Scanner scn=new Scanner(System.in); long n=scn.nextInt(); long m=scn.nextInt(); PriorityQueue<Long> pq=new PriorityQueue<>(Collections.reverseOrder()); long sum=0; for(int i=0;i<n;i++){ long a=scn.nextInt(); long b=s...
Java
["4 21\n10 8\n7 4\n3 1\n5 4", "4 16\n10 8\n7 4\n3 1\n5 4"]
1 second
["2", "-1"]
NoteIn the first example Ivan can compress the first and the third songs so after these moves the sum of sizes will be equal to $$$8 + 7 + 1 + 5 = 21 \le 21$$$. Also Ivan can compress the first and the second songs, then the sum of sizes will be equal $$$8 + 4 + 3 + 5 = 20 \le 21$$$. Note that compressing any single so...
Java 8
standard input
[ "sortings" ]
91541d10c5ae52be8da33412359bd019
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^5, 1 \le m \le 10^9$$$) β€” the number of the songs on Ivan's phone and the capacity of Ivan's flash drive. The next $$$n$$$ lines contain two integers each: the $$$i$$$-th line contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le...
1,100
If it is impossible to compress a subset of the songs in such a way that all songs fit on the flash drive, print "-1". Otherwise print the minimum number of the songs to compress.
standard output
PASSED
66c3f33a3730c254eb3928d218743fc0
train_002.jsonl
1476522300
Several years ago Tolya had n computer games and at some point of time he decided to burn them to CD. After that he wrote down the names of the games one after another in a circle on the CD in clockwise order. The names were distinct, the length of each name was equal to k. The names didn't overlap.Thus, there is a cyc...
512 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf727e { public static void main(String[] args) throws IOException { int n = rni(), k = ni(), ind[] = new int[2 * n * k]; fill(ind, -1); char[] s1 = rcha(), s = new char[2 ...
Java
["3 1\nabc\n4\nb\na\nc\nd", "4 2\naabbccdd\n4\ndd\nab\nbc\ncd"]
4 seconds
["YES\n2 1 3", "NO"]
null
Java 11
standard input
[ "data structures", "string suffix structures", "hashing", "strings" ]
ff5b3d5fa52c2505556454011e8a0f58
The first line of the input contains two positive integers n and k (1 ≀ n ≀ 105, 1 ≀ k ≀ 105)Β β€” the amount of games Tolya burned to the CD, and the length of each of the names. The second line of the input contains one string consisting of lowercase English lettersΒ β€” the string Tolya wrote on the CD, split in arbitrary...
2,300
If there is no answer, print "NO" (without quotes). Otherwise, print two lines. In the first line print "YES" (without quotes). In the second line, print n integersΒ β€” the games which names were written on the CD. You should print games in the order they could have been written on the CD, it means, in clockwise order. Y...
standard output
PASSED
9ce1fa4461b3105d55a1f39a7188f498
train_002.jsonl
1374913800
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original...
256 megabytes
import java.io.File; import java.util.Arrays; import java.util.Scanner; /** * User: xy6er * Date: 27.07.13 * Time: 13:58 */ public class D { private Scanner sc; int n, m; int[] x, y; int ans; public static void main(String[] args) throws Exception { D clazz = new D(); clazz.in...
Java
["3 1\n2 2", "3 0", "4 3\n3 1\n3 2\n3 3"]
1 second
["0", "1", "1"]
NoteIn the first test the answer equals zero as we can't put chips into the corner cells.In the second sample we can place one chip into either cell (1, 2), or cell (3, 2), or cell (2, 1), or cell (2, 3). We cannot place two chips.In the third sample we can only place one chip into either cell (2, 1), or cell (2, 4).
Java 7
standard input
[ "two pointers", "implementation", "greedy" ]
a26a97586d4efb5855aa3b930e9effa7
The first line contains two space-separated integers n and m (2 ≀ n ≀ 1000, 0 ≀ m ≀ 105) β€” the size of the field and the number of banned cells. Next m lines each contain two space-separated integers. Specifically, the i-th of these lines contains numbers xi and yi (1 ≀ xi, yi ≀ n) β€” the coordinates of the i-th banned ...
1,800
Print a single integer β€” the maximum points Gerald can earn in this game.
standard output
PASSED
7631f35b7ad38e18e82b9794c8fc8ea6
train_002.jsonl
1374913800
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original...
256 megabytes
import java.io.*; import java.util.*; public class D { FastScanner in; PrintWriter out; void solve() { int n = in.nextInt(), m = in.nextInt(); boolean r[] = new boolean[n + 1], c[] = new boolean[n + 1]; for (int i = 0; i < m; i++) { int x = in.nextInt(), y = in.nextInt(); r[y] = true; c[x] = true; ...
Java
["3 1\n2 2", "3 0", "4 3\n3 1\n3 2\n3 3"]
1 second
["0", "1", "1"]
NoteIn the first test the answer equals zero as we can't put chips into the corner cells.In the second sample we can place one chip into either cell (1, 2), or cell (3, 2), or cell (2, 1), or cell (2, 3). We cannot place two chips.In the third sample we can only place one chip into either cell (2, 1), or cell (2, 4).
Java 7
standard input
[ "two pointers", "implementation", "greedy" ]
a26a97586d4efb5855aa3b930e9effa7
The first line contains two space-separated integers n and m (2 ≀ n ≀ 1000, 0 ≀ m ≀ 105) β€” the size of the field and the number of banned cells. Next m lines each contain two space-separated integers. Specifically, the i-th of these lines contains numbers xi and yi (1 ≀ xi, yi ≀ n) β€” the coordinates of the i-th banned ...
1,800
Print a single integer β€” the maximum points Gerald can earn in this game.
standard output
PASSED
2df2237171d5d44d86ecf3598f940d04
train_002.jsonl
1374913800
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class D { public static void main(String[] args) throws Except...
Java
["3 1\n2 2", "3 0", "4 3\n3 1\n3 2\n3 3"]
1 second
["0", "1", "1"]
NoteIn the first test the answer equals zero as we can't put chips into the corner cells.In the second sample we can place one chip into either cell (1, 2), or cell (3, 2), or cell (2, 1), or cell (2, 3). We cannot place two chips.In the third sample we can only place one chip into either cell (2, 1), or cell (2, 4).
Java 7
standard input
[ "two pointers", "implementation", "greedy" ]
a26a97586d4efb5855aa3b930e9effa7
The first line contains two space-separated integers n and m (2 ≀ n ≀ 1000, 0 ≀ m ≀ 105) β€” the size of the field and the number of banned cells. Next m lines each contain two space-separated integers. Specifically, the i-th of these lines contains numbers xi and yi (1 ≀ xi, yi ≀ n) β€” the coordinates of the i-th banned ...
1,800
Print a single integer β€” the maximum points Gerald can earn in this game.
standard output
PASSED
31ce1056566cf421afba81a440c13d73
train_002.jsonl
1374913800
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; public class D { /** * @param args */ public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String str = bf.readLine(); int n = Int...
Java
["3 1\n2 2", "3 0", "4 3\n3 1\n3 2\n3 3"]
1 second
["0", "1", "1"]
NoteIn the first test the answer equals zero as we can't put chips into the corner cells.In the second sample we can place one chip into either cell (1, 2), or cell (3, 2), or cell (2, 1), or cell (2, 3). We cannot place two chips.In the third sample we can only place one chip into either cell (2, 1), or cell (2, 4).
Java 7
standard input
[ "two pointers", "implementation", "greedy" ]
a26a97586d4efb5855aa3b930e9effa7
The first line contains two space-separated integers n and m (2 ≀ n ≀ 1000, 0 ≀ m ≀ 105) β€” the size of the field and the number of banned cells. Next m lines each contain two space-separated integers. Specifically, the i-th of these lines contains numbers xi and yi (1 ≀ xi, yi ≀ n) β€” the coordinates of the i-th banned ...
1,800
Print a single integer β€” the maximum points Gerald can earn in this game.
standard output
PASSED
519101c7d9c1937a6ad6c6309964ee3b
train_002.jsonl
1374913800
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original...
256 megabytes
import java.util.Scanner; import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Sabelan */ public class Main { public static void main(String[] args) { InputStream inputStream =...
Java
["3 1\n2 2", "3 0", "4 3\n3 1\n3 2\n3 3"]
1 second
["0", "1", "1"]
NoteIn the first test the answer equals zero as we can't put chips into the corner cells.In the second sample we can place one chip into either cell (1, 2), or cell (3, 2), or cell (2, 1), or cell (2, 3). We cannot place two chips.In the third sample we can only place one chip into either cell (2, 1), or cell (2, 4).
Java 7
standard input
[ "two pointers", "implementation", "greedy" ]
a26a97586d4efb5855aa3b930e9effa7
The first line contains two space-separated integers n and m (2 ≀ n ≀ 1000, 0 ≀ m ≀ 105) β€” the size of the field and the number of banned cells. Next m lines each contain two space-separated integers. Specifically, the i-th of these lines contains numbers xi and yi (1 ≀ xi, yi ≀ n) β€” the coordinates of the i-th banned ...
1,800
Print a single integer β€” the maximum points Gerald can earn in this game.
standard output
PASSED
4703dadfcb581e7b5e4f9a1aed493490
train_002.jsonl
1374913800
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original...
256 megabytes
import java.io.*; import java.util.*; public class D { private static StringTokenizer tokenizer; private static BufferedReader bf; private static PrintWriter out; private static int nextInt() throws IOException { return Integer.parseInt(nextToken()); } private static String nextToken(...
Java
["3 1\n2 2", "3 0", "4 3\n3 1\n3 2\n3 3"]
1 second
["0", "1", "1"]
NoteIn the first test the answer equals zero as we can't put chips into the corner cells.In the second sample we can place one chip into either cell (1, 2), or cell (3, 2), or cell (2, 1), or cell (2, 3). We cannot place two chips.In the third sample we can only place one chip into either cell (2, 1), or cell (2, 4).
Java 7
standard input
[ "two pointers", "implementation", "greedy" ]
a26a97586d4efb5855aa3b930e9effa7
The first line contains two space-separated integers n and m (2 ≀ n ≀ 1000, 0 ≀ m ≀ 105) β€” the size of the field and the number of banned cells. Next m lines each contain two space-separated integers. Specifically, the i-th of these lines contains numbers xi and yi (1 ≀ xi, yi ≀ n) β€” the coordinates of the i-th banned ...
1,800
Print a single integer β€” the maximum points Gerald can earn in this game.
standard output
PASSED
17c2125595075dd7291bdab5fedf588b
train_002.jsonl
1374913800
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original...
256 megabytes
import java.io.*; import java.util.*; public class D { private static StringTokenizer tokenizer; private static BufferedReader bf; private static PrintWriter out; private static int nextInt() throws IOException { return Integer.parseInt(nextToken()); } private static String nextToken(...
Java
["3 1\n2 2", "3 0", "4 3\n3 1\n3 2\n3 3"]
1 second
["0", "1", "1"]
NoteIn the first test the answer equals zero as we can't put chips into the corner cells.In the second sample we can place one chip into either cell (1, 2), or cell (3, 2), or cell (2, 1), or cell (2, 3). We cannot place two chips.In the third sample we can only place one chip into either cell (2, 1), or cell (2, 4).
Java 7
standard input
[ "two pointers", "implementation", "greedy" ]
a26a97586d4efb5855aa3b930e9effa7
The first line contains two space-separated integers n and m (2 ≀ n ≀ 1000, 0 ≀ m ≀ 105) β€” the size of the field and the number of banned cells. Next m lines each contain two space-separated integers. Specifically, the i-th of these lines contains numbers xi and yi (1 ≀ xi, yi ≀ n) β€” the coordinates of the i-th banned ...
1,800
Print a single integer β€” the maximum points Gerald can earn in this game.
standard output
PASSED
3a782ae6d0d9e443cdc4570edbce6854
train_002.jsonl
1374913800
Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from its original...
256 megabytes
/** * Created with IntelliJ IDEA. * User: IAIN * Date: 9/08/13 * Time: 11:03 AM * To change this template use File | Settings | File Templates. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public cla...
Java
["3 1\n2 2", "3 0", "4 3\n3 1\n3 2\n3 3"]
1 second
["0", "1", "1"]
NoteIn the first test the answer equals zero as we can't put chips into the corner cells.In the second sample we can place one chip into either cell (1, 2), or cell (3, 2), or cell (2, 1), or cell (2, 3). We cannot place two chips.In the third sample we can only place one chip into either cell (2, 1), or cell (2, 4).
Java 7
standard input
[ "two pointers", "implementation", "greedy" ]
a26a97586d4efb5855aa3b930e9effa7
The first line contains two space-separated integers n and m (2 ≀ n ≀ 1000, 0 ≀ m ≀ 105) β€” the size of the field and the number of banned cells. Next m lines each contain two space-separated integers. Specifically, the i-th of these lines contains numbers xi and yi (1 ≀ xi, yi ≀ n) β€” the coordinates of the i-th banned ...
1,800
Print a single integer β€” the maximum points Gerald can earn in this game.
standard output