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
ed7d17c9eb17f987f437a255db66bd28
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.Scanner; import java.util.Vector; public class Main { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int x =scanner.nextInt(); String str=scanner.next(); int b =0, w=0; for(int i=0;i<x;i++){ if(str.charAt(i)=='B')b+...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
5a6351ce138a459fab46b023d1f5c2ec
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public final class Main { public static void main (String[] args) throws java.lang.Exception { Scanner s = new Scanner(System.in); ...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
2e65a08c8e422aa89a2e05826f0b7df4
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
/* *created by Kraken on 08-04-2020 at 13:21 */ //package com.kraken.cf.cf608; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class B { public static void main(String[] args) { FastReader sc = n...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
dddec2d28d1f5001a1ef4e5ace260ce7
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.math.BigInteger; import java.text.Format; import java.util.Arrays; import java.util.Scanner; public class Main { // final static int N = (int) (1e5 + 10); static int sum; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); char[] a=new char[210]; int [...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
a2059c6ba7da10b2bccdfbb73ac1094d
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class Q2 { public static void main(String[] args) throws IOException { // ...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
af16ff3a2626b95a0c7253a43c3a2e5c
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class Q2 { public static void main(String[] args) throws IOException { // ...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
c1e0eb035f9cb76681e0a1275f58f706
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
//package CodeforcesProject; import java.io.*; import java.lang.*; import java.util.*; import java.util.function.BiFunction; public class Main extends IO { public static void main(String[] args) throws Exception { int quantity = readInt(); String[] base = readArrayString(""); long answer ...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
3d3c29cf44d05ae8ea2b9fb293928da6
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class Main { public static void main(String[] args) throws IOException { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
cfde3a21d374d36df7e4da38b315d63e
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.Scanner; public class Codeforces1271B_Real { public static void main(String[] args) { Scanner input = new Scanner(System.in); int length = input.nextInt(); input.nextLine(); String given = input.nextLine(); int countW = 0; int i; for (i = 0; i < given.length(); i++) { if (given.charA...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
9fe323bec5f97c58189858974c439b8e
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.math.*; import java.io.*; import java.util.*; import java.awt.*; public class CP { public static void main(String[] args) throws Exception { /*new Thread(null, new Runnable() { @Override public void run() { try { new Solver().solve();...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
44ed44c3a490fd0f8a550577c61ddbd6
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Blocks { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); String st = s.next(); s.close(); int[] arr = new int[n]; for (int i=0;i<n;i++) arr[i] = st.charAt(i)=='W'?1:0; StringBuilder res ...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
005670f477dc0e114676cd48a80831db
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Cf131 implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int ...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
11179cdc1ab158234eb95ff74c75e48d
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.Scanner; public class BAy { public static void main(String[] args) { int num; String s; Scanner scan = new Scanner(System.in); num=scan.nextInt(); s=scan.next(); char[] s1 = s.toCharArray(); char[] s2 = s.toCharArray(); int dex=0; int arr[] = new int[num]; for(int i=0;i<num-1;i++){ ...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
c831c523e9c62f19807392be91fc8824
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
// practice with kaiboy import java.io.*; import java.util.*; public class CF1271B extends PrintWriter { CF1271B() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1271B o = new CF1271B(); o.main(); o.flush(); } int[] qu; int cnt; boolean solve(byte[] a...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
d526b4647705cbdf48b12af1d9e8abff
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); U...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
0d6ae718a79af95157661dcc9ace4fbc
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { MScanner sc = new MScanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n=sc.nextInt(); char[]in=sc.nextLine().toCharArray(); int b=0;int w=0; for(char x:in) { if(x=='B'...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
e349bfbedb83e09b764551ebdf8cd5b5
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.*; public class Main { public static void printAns(Vector<Integer> v) { System.out.println(v.size()); for(Integer i : v) System.out.print(i + " "); } public static void checkInvert(Vector<Integer> v, boolean[] a, int i, int j, int k) { if(a[i] != a[j...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
72f4b8d0ddeb724778fa52c53bd95fcb
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in=new Scanner(System.in); int l=in.nextInt(); String x=in.next(); int a[]=new int[l]; int z[]=new int[l]; int b=0,w=0; boolean t=true; for(int i=0;i<l;i++) { if(x...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
3434951649c011416b9d00e53c1a013e
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class test { public static void main(String[] args) { // int test = fs.nextInt(); int test = 1; for (int cases = 0; cases < test; cases++) { int n = fs.nextInt(); String s = fs.next(); boolean ans1 = false; boolean ans2 = false; Str...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
34e95bf573060ff5c29ad6fcf5124551
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n =sc.nextInt(); char[] s = sc.next().toCharArray(); if(allSameCharacters(s)){ System.out.println(0); ...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
f0c367b47c667fabe3f90e888c45ec7b
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { int n; String s; Scanner sc = new Scanner(System.in); n=sc.nextInt(); s=sc.next(); char[] s1 = s.toCharArray(); char[] s2 = s.toCharArray(); // All Black int index=0; int arr[] = new int[n]; for(int i...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
37102404d37d362e0da336505cc152de
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { int n; String s; Scanner sc = new Scanner(System.in); n=sc.nextInt(); s=sc.next(); char[] s1 = s.toCharArray(); char[] s2 = s.toCharArray(); // All Black int index=0; int arr[] = new int[n]; for(int i=0;i<n-1;i++...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
d560dbd4f7d5699fd5f8768c042689cd
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.Scanner; import java.util.ArrayList; import java.util.List; public class ProbB { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=0; List<Integer> l = new ArrayList<>(); n = sc.nextInt(); String s = sc.next(); char a[] = s.toCharArray(); ...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
e50a5af67b4756123b7ab5307421e22c
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]){ Scanner sc = new Scanner(System.in); int l = sc.nextInt(), last_index=-1, curr_index=-1; char[] arr = sc.next().toCharArray(); String str = new String(); int count_b =0, count_w=0, count=0; ...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
e8155206fc91879c73a1bd781a06525f
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
//package com.company; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; //import java.nio.file.Paths; import java.util.*; public class Main { public static void main(String[] args) throws IOException { // write your code here ...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
006a35b4c46f97314ae7342d7f760902
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.io.*; import java.util.*; public class R608B { public static void main(String[] args) { JS scan = new JS(); int n= scan.nextInt(); char[] s = scan.next().toCharArray(); int w = 0, b= 0 ; for(int i = 0;i<s.length;i++) { if(s[i]=='W')w++; else b++; } ArrayList<Integer> ans = new ArrayLis...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
11f3165594394ff8a0f69a7f5d26067c
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.*; import java.io.*; public class Main { static final int MOD_PRIME = 1000000007; public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStre...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
3d5e510a7b7e57d7819de582fbbf16f3
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int len,len1,flag=0,sum[]=new int[606],k; int b=0,w=0; k=0; len=sc.nextInt(); char str[]=sc.next().toCharArray(); for(int i=0;i<str.length;i++) { if(str[i]...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
2e27bc4ed0bffc5db423114276e22c50
train_001.jsonl
1576401300
There are $$$n$$$ blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white. You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa). You want to find a sequence of o...
256 megabytes
import java.util.*; public class Blocks{ static Scanner in=new Scanner(System.in); public static void main(String array[]){ int n=in.nextInt(); char ch[]=in.next().toCharArray(); int white=0,black=0; ArrayList<Integer> list=new ArrayList<Integer>(); for(int i=0;i<n;i++){ if(ch[i]=='W...
Java
["8\nBWWWWWWB", "4\nBWBB", "5\nWWWWW", "3\nBWB"]
2 seconds
["3\n6 2 4", "-1", "0", "2\n2 1"]
NoteIn the first example, it is possible to make all blocks black in $$$3$$$ operations. Start with changing blocks $$$6$$$ and $$$7$$$, so the sequence is "BWWWWBBB". Then change blocks $$$2$$$ and $$$3$$$, so the sequence is "BBBWWBB". And finally, change blocks $$$4$$$ and $$$5$$$, so all blocks are black.It is impo...
Java 11
standard input
[ "greedy", "math" ]
3336662e6362693b8ac9455d4c2fe158
The first line contains one integer $$$n$$$ ($$$2 \le n \le 200$$$) — the number of blocks. The second line contains one string $$$s$$$ consisting of $$$n$$$ characters, each character is either "W" or "B". If the $$$i$$$-th character is "W", then the $$$i$$$-th block is white. If the $$$i$$$-th character is "B", then ...
1,300
If it is impossible to make all the blocks having the same color, print $$$-1$$$. Otherwise, print an integer $$$k$$$ ($$$0 \le k \le 3 \cdot n$$$) — the number of operations. Then print $$$k$$$ integers $$$p_1, p_2, \dots, p_k$$$ $$$(1 \le p_j \le n - 1)$$$, where $$$p_j$$$ is the position of the left block in the pai...
standard output
PASSED
791448f8f4e7da93588168f7f496907b
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.util.*; import java.io.*; public class Main { static class Scan { private byte[] buf=new byte[1024]; private int index; private InputStream in; private int total; public Scan() { in=System.in; } public int scan()throws IOExcepti...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 11
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≤ xi ≤ 105) — the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase letters— the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
4bfa4a56f7bec33acdf040718cb607c5
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Map; import java.util.Scanner; import java.util.HashMap; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Kraken */ public class Main { public static vo...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 11
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≤ xi ≤ 105) — the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase letters— the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
89a31593e7c03a7aab217ac5ebc79861
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.util.*; public class Solution { public static void main(String []args) { Scanner sc = new Scanner(System.in); long arr[] = new long[26]; for(int i = 0 ; i < 26 ; i++) { arr[i] = sc.nextLong(); } ...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 11
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≤ xi ≤ 105) — the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase letters— the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
de486671b4b93273be1e989541120ba7
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.*; import java.util.*; public class AAndBInterestingSubstrings{ public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int[] arr = new int[26...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 11
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≤ xi ≤ 105) — the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase letters— the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
3f2ebf5f1c021058b73980317d45df67
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void r(int arr[],int l,int m,int r) { int n1=m-l+1; int n2=r-m; int L[]=new int[n1]; int R[]=new int[n2]; for(int i=0;i<n1;i++) { L[i]=arr[l+i]; } for(int j=0;j<n2;j++) { R[j]=arr[m+1+j]; } int i...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 11
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≤ xi ≤ 105) — the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase letters— the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
ab38d36e4ef65352f470f5529155bf15
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.StringTokenizer; public class Main { static PrintWriter out = new Print...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 11
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≤ xi ≤ 105) — the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase letters— the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
4a670cc070b268e7e77528682c8718be
train_001.jsonl
1425128400
A and B are preparing themselves for programming contests.After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.A likes lowercase letters of the Latin alphabet. He has assigned to each letter a numb...
256 megabytes
//package com.company; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.sql.SQLOutput; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner s = new Scanner(System.i...
Java
["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa"]
2 seconds
["2", "2"]
NoteIn the first sample test strings satisfying the condition above are abca and bcab.In the second sample test strings satisfying the condition above are two occurences of aa.
Java 11
standard input
[ "dp", "two pointers", "data structures" ]
0dd2758f432542fa82ff949d19496346
The first line contains 26 integers xa, xb, ..., xz ( - 105 ≤ xi ≤ 105) — the value assigned to letters a, b, c, ..., z respectively. The second line contains string s of length between 1 and 105 characters, consisting of Lating lowercase letters— the string for which you need to calculate the answer.
1,800
Print the answer to the problem.
standard output
PASSED
0168f1bf8d389907ef873964b6253109
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.BufferedReader; import java.io.Reader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in *...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
8daa0e4f5a06ad838dc68ed3d84bc97c
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
import java.util.*; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.OutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; public class ArrayBeauty { public static void main(String[] args) { InputStr...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
895a4741d4613911674576be9e64fd45
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
import java.io.*; import java.util.*; public class A { FastScanner in; PrintWriter out; final int mod = 998244353; int add(int x, int y) { x += y; return x >= mod ? (x - mod) : x; } void solve() { int n = in.nextInt(); int k = in.nextInt(); int[] a = n...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
0aaa4f29c1deb7905b99eca398483449
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.concurrent.ThreadLocalRandom; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import j...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
f6845c8bae943e678fe16548c6bb5a48
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
// upsolve with rainboy import java.io.*; import java.util.*; public class CF1188C extends PrintWriter { CF1188C() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1188C o = new CF1188C(); o.main(); o.flush(); } static final int MD = 998244353; void mai...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
3f8033fd29922a51bbf2e7510cc0b075
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.charset.Charset; import java.util.Arrays; public class CF1188C { public static void main(String[] args) throws Exception { boolean local = System.getProperty("ONLINE_JUDGE")...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
1594ca44705cd736f0abfa7d8d4a72d2
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
64868705aa53f1682ab85afec6aaa839
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
46bdf252c64a0e4655d95663d1b99fcb
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
4635f6004a6a0beb1737fcbc9737aa5f
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
975d1ae88d92dd3f67f27a00f3ba145f
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
d786b56419aec4fc2b0e1293b7180058
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
e591dbc2d84bf1c1e9de23ecbe4b212a
train_001.jsonl
1562339100
Let's call beauty of an array $$$b_1, b_2, \ldots, b_n$$$ ($$$n &gt; 1$$$)  — $$$\min\limits_{1 \leq i &lt; j \leq n} |b_i - b_j|$$$.You're given an array $$$a_1, a_2, \ldots a_n$$$ and a number $$$k$$$. Calculate the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author k...
Java
["4 3\n1 7 3 5", "5 5\n1 10 100 1000 10000"]
5 seconds
["8", "9"]
NoteIn the first example, there are $$$4$$$ subsequences of length $$$3$$$ — $$$[1, 7, 3]$$$, $$$[1, 3, 5]$$$, $$$[7, 3, 5]$$$, $$$[1, 7, 5]$$$, each of which has beauty $$$2$$$, so answer is $$$8$$$.In the second example, there is only one subsequence of length $$$5$$$ — the whole array, which has the beauty equal to ...
Java 8
standard input
[ "dp" ]
624bf3063400fd0c2c466295ff63469b
The first line contains integers $$$n, k$$$ ($$$2 \le k \le n \le 1000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^5$$$).
2,500
Output one integer — the sum of beauty over all subsequences of the array of length exactly $$$k$$$. As this number can be very large, output it modulo $$$998244353$$$.
standard output
PASSED
5d6f03c9e9f46b24399c091d6c34eb93
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
//package com.company.CompititivePrograming; import java.io.*; import java.util.ArrayList; public class AirConditioner { static class Pair { long arrivalTime, reqMin, reqMax; Pair(long arrivalTime, long reqMin, long reqMax) { this.reqMax = reqMax; this.arrivalTime = arriva...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
ce22ca7300d3ed940825f2c0e56f6cc1
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.io.*; public class C { private static int n = 0; private static int m = 0; private static int[] time = null; private static int[] lb = null; private static int[] ub = null; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(ne...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
983ac2e48913ee5ff5a66982c7ef17a7
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Random; import java.io.PrintWriter; /* Solution Created: 18:48:01 15/02/2020 Custom Compet...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
2cbdd5332245dda6caa2850dafb96d81
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
//package Round620; import java.util.Scanner; /** * @author sguar <shugangcao@gmail.com> * welcome to kuaishou * Created on 2020-02-12 */ public class C { public static void main(String[] args) { new C().run(); } private void run() { Scanner cin = new Scanner(System.in); //Pr...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
5992afa58df6f0fe22d5a0fa6e119ff0
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
/** * Created by trung.pham on 14/7/19. */ import java.util.*; import java.io.*; public class C_Round_620_Div2 { public static long MOD = 998244353; public static void main(String[] args) throws FileNotFoundException { // PrintWriter out = new PrintWriter(new FileOutputStream(new File( // ...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
dbbb375ad33ae221113f49cbc201200f
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static long gcd(long n, long m){ if(m > n) return gcd(m,n); if(m == 0) return n; return gcd(m, n%m);} public static long lcm(long m, long n){ return (m/gcd(m,n))*n;} static int mod = 1000000007; static int INF = Integer.MAX_VALUE; static int[] dx = ...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
116107fe616324757bb19e7238cac8f9
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.math.BigInteger; import java.util.Scanner; import...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
871a65749c419df8fa897b681717c44c
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.util.*; import java.io.*; public class ac { public static void main (String[] args) { Scanner sc=new Scanner(System.in); int q=sc.nextInt(); while(q-->0){ int n=sc.nextInt(); int m=sc.nextInt(); int t[]=new int[n]; int l[]=new int[n]; int r[]=new int...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
fdf4160870cb87ad3d7821f4e8e3e39b
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.util.Scanner; public class a { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); for (int i = 0; i < t; i++) { int count = scanner.nextInt(); int temp = scanner.nextInt(); int up = ...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
838807cafab963080a0a195346a82b65
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.StringTokenizer; public class c620 { static PrintWriter out; static BufferedReader in; static StringTokenizer st; public static void main(String[] args) throws FileNotFoundException { //out = new PrintWriter("test.out"); /...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
4e8b79a298a4d19e376e6720394e411a
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
/*****Author: Satyajeet Singh************************************/ import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.*; public class Main{ /*********************************************Constants******************************************/ static Print...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
ab795595c9af57d5f86f5355a2992c69
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeSet; public class Q1 { public static void main(String[] args) { mYScanner in = new mYScanner(); int t = in....
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
8920d6bbd6af1e740eb9f5f033981b9d
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
/** * BaZ :D */ import java.util.*; import java.io.*; import static java.lang.Math.*; public class ACMIND { static MyScanner scan; static PrintWriter pw; static long MOD = 1_000_000_007; static long INF = 1_000_000_000_000_000_000L; static long inf = 2_000_000_000; public static void main(St...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
72c836d9d7877053740eacf2b832a089
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main (String[] args) { int t; Scanner scan=new Scanner(System.in); t=scan.nextInt(); OUTER: while(t--!=0) { int n; long initial_temp; n=scan.nextInt(); long temp[]=new long[n+1]; ...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
e1b3e6fbbcfc368052179d61afed6a17
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.io.*; import java.util.*; public class CodeForces{ public static pair update(pair curr,long a,long b) { curr.s=Math.max(curr.s,a); curr.e=Math.min(curr.e,b); return curr; } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedRead...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
0dc5220f029cffadc75805ce92f053d6
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { BufferedReader bf = new BufferedReader(new ...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
ee482ed7ab1a31cab79b9af0de812332
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
//package com.pb.codeforces.practice; import java.util.Scanner; public class CF1304C { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while(t-- > 0) { int n = in.nextInt(); long s = in.nextInt(); long e = s; long pt = 0; boolean possible = true; ...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
68199d11b7e8ad8b916956b09aed6156
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.io.*; import java.util.*; public class Sol{ final public static int INF = Integer.MAX_VALUE; public static void main(String[] args) throws IOException{ FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int q = sc.nextInt(); while(q-->0) { int n...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
dfb6d7453f0dc4bff82448958d4b35fd
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.util.ArrayList; import java.util.List; import java.util.Scanner; /** * https://codeforces.com/contest/1304/problem/C */ public class C { public static void main(String[] args) { Scanner in = new Scanner(System.in); int q = Integer.parseInt(in.nextLine()); for (int i = 0; i <...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
a84004e682b29f4560bfb109f232c3d5
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.awt.Point; public class Main { //static final long MOD = 998244353L; //static final long INF = -1000000000000000007L; static final long MOD = 1000000007L; //static final int INF = 1000000007; static long[] factorial; public static void ma...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
166185f75557eeb7e2582b18f34cf793
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** If I'm the sun, you're the moon Because when I go up, you go down ******************************* */ import java.util.*; import java.io.*; public class C2 { public static ...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
5caa36d9cb50f4ad63049772f9261f83
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ public static class pair{ int x; int y; } public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine())...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
e577cc8c5693c82e95e6aed13899b589
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; public class _testing { static boolean isPalindrome(String str) { // Pointers pointing to the beginning // and the end of the string int i = 0, j = str.length() - 1; ...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
dd8ef521f7101d9bfb999d1511a7a8f0
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.util.*; import java.util.Arrays; public class solve { public static void main(String args[]) { Scanner in=new Scanner(System.in); int q=in.nextInt(); while(q!=0) { q--; int n=in.nextInt(); int m=in.nextInt(); int t[]=new int[n]; int l[...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
8ced0ec25644c60d00d9cad81dc7047d
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import org.w3c.dom.ls.LSOutput; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Hello { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int numTestCases = scanner.nextInt(); while (n...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
229734fc4dc9ea19e050bf95124b34e7
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Compare compare = new Compare(); Scanner scanner = new Scanner(System.in); int q = scanner.nextInt(); for (int i = 0; i < q; i++) { int n = scanner.nextIn...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
3ce70f196f16b8a521963d138c7a9a80
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.*; public class AC { public static void main (String[] args) { Scanner sc=new Scanner(System.in); int t,i; t=sc.nextInt(); while(t>0) { t--; int n=sc.nextInt(); int m=sc.nextInt(); int a[][]=new int[n][3]; for(i=0;i<n;i++...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
accdcd4dc3577bbe016ff4a03de1685b
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
9ca9448c8debec0e867fdb06897c3d3a
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.util.Scanner; public class WorkFile { public static void main(String[] args) { Scanner s = new Scanner(System.in); int q = s.nextInt(); StringBuilder res = new StringBuilder(); while (q-->0) { int n = s.nextInt(), m = s.nextInt(); long t1 = 0, min...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
5f7c3cc9629cfa7e3b49c82b1477017e
train_001.jsonl
1581771900
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custome...
256 megabytes
import java.util.Scanner; public class WorkFile { public static void main(String[] args) { Scanner s = new Scanner(System.in); int q = s.nextInt(); while (q-->0) { int n = s.nextInt(), m = s.nextInt(); long t1 = 0, min = m, max = m, k = 0; for (int i=0; i...
Java
["4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0"]
1 second
["YES\nNO\nYES\nNO"]
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way: At $$$0$$$-th minute, change the state to heating (the temperature is 0). At $$$2$$$-nd minute, change the state to off (the temperature is 2). At $$$5$$$-th minute, change the state to heating (the temperat...
Java 8
standard input
[ "dp", "greedy", "two pointers", "implementation", "sortings" ]
a75b8b9b99b800762645ef7c3bc29905
Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number ...
1,500
For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).
standard output
PASSED
9e2860bb251bc04b53304b1b90b2674f
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.util.*; import java.io.*; public class C { public static void main(String[] args) { FastScanner sc = new FastScanner(); int N = sc.nextInt(); int K = sc.nextInt(); int[] heights = new int[200001]; for (int i = 0; i < N; i++) { int H = sc.nextInt(); ...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
e47a8b60a3f1a92eaed7190fdb987058
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.util.Arrays; import java.util.Scanner; import java.util.Stack; public class MakeEqual { static class whonum{ int height,num; } public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int hlim = sc.nextInt(); Stac...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
0dba2fd173bfb73b2a9e9f901a253c99
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.TreeSet; public class CF1065C { static long maxH = (long)(2*(Math.pow(10,5))+5); public static void main(String[] args) { FastReader fr = new FastReader(); ...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
6b4cd93d091711cd3fbe9d9f200ef084
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { private static Reader in; private static PrintWriter out; static class Reader { private BufferedReader br; private StringTokenizer token; protected Reader(FileReader obj) { br = new...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
e989f8278c236568b2f8f3166553b2d7
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { private static Reader in; private static PrintWriter out; static class Reader { private BufferedReader br; private StringTokenizer token; protected Reader(FileReader obj) { br = new...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
25480ad494d5aa118b823334b648b969
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; PrintWriter out; public FastReader(boolean fileInput) throws IOException { Reader reader = fileInput ? new FileReader("balls.in") : new InputStre...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
2acd699da21ce93c367125caab6a9acc
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.util.Scanner; public class CCC { public static void main(String args[]) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); int k=scan.nextInt(); int height[]=new int[200001]; long cost=0l; int min=Integer.MAX_VALUE; int max=0; for(int i=0;i<n;i++) { int add=scan.nextInt(...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
2e83219cef613006712bee153878fb25
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); //////////////////////////////////////////////////////////////////////// int nu...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
efaea7dee21d0d6d250e9c0bdb5ad7a4
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.*; import java.util.*; public class TaskC { public static void main(String[] args) { new TaskC(System.in, System.out); } static class Solver implements Runnable { int n, k, lim; int[] heights; long[] cnt; InputReader in; PrintWriter out; void solve() throws IOException { n = in...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
3508a380fa3f0a4fc83128c82e338902
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class CF1065C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long k = sc.nextLong(); int[] ...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
b33ee9bf84f43aba3045a12166fc1ddd
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.util.*; import java.io.*; public class C { static final boolean stdin = true; static final String filename = ""; static FastScanner br; static PrintWriter pw; public static void main(String[] args) throws IOException { if (stdin) { br = new FastScanner(); pw = new PrintWriter(new OutputStr...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
f959a57054fd74847148379b2ae322c2
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.util.Scanner; /** * Contest: Educational Codeforces Round 52 * * @author Arturs Licis */ public class ProblemC { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long k = sc.nextLong(); long[] h = new long[200_000 + 1]; long min = Long.MAX...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
cc89fdfcb4dab879bcd8151e10226900
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class Main { private static Scanner sc; private static Printer pr; static boolean []visited; static int []color; static int []pow=new int[(int)3e5+1]; static int []count; static boole...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
ae098154732b85f0430f18fda041c9b2
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
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 ou...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
9f14925fc217debf18974552f290ba7d
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
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 ou...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
02dad0f3cf89608a6ef63a583f4d02de
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; import java.util.HashMap; import java.util.PriorityQueue; public class templ implements Runnable { class pair { int f,s; pair(int fi,int se) { f=fi; s=se; } } void merge1(int arr[], int l, i...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
62815aee7bec362c77aac7d6ab09d510
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.OutputStream; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @autho...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
ee31fefea192bb17fcfb9f6976220dc5
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Vad...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
3f02da3f0e0a44ceb7e0f664e78ff526
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.stream.IntStream; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.util.Random; import java.io.BufferedReader; import java.io.InputStreamRea...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
3d3e0f24b37d69a93fd9db91c593876f
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class vk18 { public static void main(String[] stp) throws Exception { Scanner scan = new Scanner(System.in); P...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output
PASSED
68465af8d7d422b290439b0e9be197da
train_001.jsonl
1539269400
There is a toy building consisting of $$$n$$$ towers. Each tower consists of several cubes standing on each other. The $$$i$$$-th tower consists of $$$h_i$$$ cubes, so it has height $$$h_i$$$.Let's define operation slice on some height $$$H$$$ as following: for each tower $$$i$$$, if its height is greater than $$$H$$$,...
256 megabytes
import java.io.*; import java.util.*; public class Main { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) throws IOException { scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); int n = scanner.nextInt(); int k = scanner.nextInt(); ...
Java
["5 5\n3 1 2 2 4", "4 5\n2 3 4 5"]
2 seconds
["2", "2"]
NoteIn the first example it's optimal to make $$$2$$$ slices. The first slice is on height $$$2$$$ (its cost is $$$3$$$), and the second one is on height $$$1$$$ (its cost is $$$4$$$).
Java 8
standard input
[ "greedy" ]
676729309dfbdf4c9d9d7c457a129608
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$n \le k \le 10^9$$$) — the number of towers and the restriction on slices, respectively. The second line contains $$$n$$$ space separated integers $$$h_1, h_2, \dots, h_n$$$ ($$$1 \le h_i \le 2 \cdot 10^5$$$) — the initial heig...
1,600
Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth.
standard output