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
620f9e9163986398b593bb535a2e5a98
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.*; public class Problem60 { public static void main(String[] args) { Scanner read=new Scanner(System.in); int n=read.nextInt(),k=read.nextInt(); int covered=0; for(int i=0 ; i<n ; i++) { int l=read.nextInt(); int r=read.nextInt(); covered+=(r-l+1); } covered%=k; if(covered!...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
425107d038a5a4655cc9635bada951b1
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int k = input.nextInt(); int[] x = new int[n]; int[] y = new int[n]; int[] temp = new int[n]; int cou...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
c75c10ec9677e67285e9b9e2d365216b
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class A289 { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int a ; int b ; int x = 0; for (int i = 0 ; i < n ; i++){ a = in.nextInt(); ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
d23949931095e9549d6217d2318812d3
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class a { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n=s.nextInt(); int k=s.nextInt(); int sum=0; for(int i=0;i<n;i++){ ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
5aa8743751aeb223e3bef047ed7dbb80
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; /** * @author Abdelrahman Mamdouh */ public class solve { public static void main(String[] args) { Scanner abd =new Scanner(System.in); int x=abd.nextInt(),z=abd.nextInt(),r=0,l=0,c=0; for(int i=0;i<x;i++){ l=abd.nextInt();r=abd....
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
7ebb80683e4365ade6c9efc4df4417b3
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class JavaApplication37 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); int sum=0; for(int i=0;i<n;i++){ int c=sc.nextInt(); int v=sc.nextInt...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
ebdc736c38fa933cd6387bc0dd446a0c
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class PoloThePenguinAndSegments { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); int k=in.nextInt(); int length=0; for(int i=0;i<n;i++) { int r=in.nextInt(); int l=in.nextInt(); l...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
7fb53739f3868b9b80a8dcfc83949c95
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int sum = 0; for(int i = 0; i < n; i++){ int l = in.nextInt(); int r = in.nextInt(); sum += r - l + 1; } int ans = 0; System.out.p...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
72be8ed49768a2928ad88e83b5f3e74f
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.*; import java.util.*; public final class code // public class Main // class code // public class Solution { static void solve()throws IOException { int n=nextInt(); int k=nextInt(); int sum=0; for(int i=1;i<=n;i++) { int l=nextInt(); ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
3b0cad5ed902e566aedba8bd4a77cbc8
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws Exception{ Scanner sc = new Scanner(System.in); PrintWriter ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
186f7eb1bcd5551ddd6d020ef5581d1e
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class main{ public static void main(String[] args){ Scanner sc= new Scanner(System.in); int ar[]; ar = new int[sc.nextInt()*2]; int k = sc.nextInt(); for(int i=0;i<ar.length;i++){ ar[i]=sc.nextInt();...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
c647ce8ae1be77c7e57c865521d597e7
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.Buffer...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
a6a46e2e3e47ce522238bd64bf3a4951
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class A289_Polo_the_Penguin_and_Segments { public static void main(String[] args) { Scanner ss = new Scanner (System.in ) ; int n = ss.nextInt() ; int k = ss.nextInt() ; int x = 0 ; for (int i = 0 ; i < n ; ++ i ) { int f = ss.nextInt() ; int s = ss.nextInt(); ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
2f8fae9c70c051be67e78d4a3dddc99e
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class JavaApplication2 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); int k=in.nextInt(); int sum=0; for(int i=0;i<n;i++) { int a=in.nextInt(); int b...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
7bbd407c1d026fef6f8b40f476ef29aa
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { boolean env=System.getProperty("ONLINE_JUDGE") != null; if(!env) { try { ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
f31860a69011e489e897143949c33d6b
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int k=input.nextInt(); int nm=0; for(int i=0;i<n;i++){ int s=...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
bef211f66cac6792e273a7cb9b92c352
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { FastReader read = new FastReader(); StringBuilder out = new StringBuilder(); int n...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
22e6f53b13deac70542c431028510a59
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; /** * * @author sokol */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner in = new Scanner(System.in); int n = in.nextInt(); int sum =...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
3a55bb32ee45bdcafd03e860925ea90c
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class CodeForces { public static void main(String[] args) throws IOException { reader input = new reader(); int n=input.nextInt(); int k=input.nextInt(); ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
af8adb0b78e65fd2a5d1164ac8a61e7b
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.math.BigInteger; import java.util.regex.*; public class Test { public static long mod = 1000000007; public static void main(String[] args) { FastReader cin = new FastReader(System.in); PrintWriter cout = ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
198aef0747a49993dfd604d0d3b0d6be
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.HashSet; import java.util.Scanner; public class JavaApplication55 { public static void main(String[] args) { Scanner s=new Scanner(System.in); HashSet<Integer> set=new HashSet(); int n=s.nextInt(),k=s.nextInt(); int x,y; for (int i = 0; i < n; i++) { ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
e96bc11a23667cba0aebaea7063d8bbb
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class CF177A { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int k = scan.nextInt(); long count = 0; for(int i = 0; i < n; i++){ int left = scan.nextInt(); int right = scan.nextInt(); count += (right-left)+1...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
e7c21b75280c2dfbc76ce356d4c0d3d7
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import static java.lang.System.exit; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Scanner; import java.util.*; /** * * @author abdelmagied */ import java.util.ArrayList; import java.util.Collections; import java....
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
e082935ca1656b54e297cbbe81dcf7e1
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class PoloThePenguinAndSegments implements Closeable { private InputReader in = new InputReader(S...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
580ec27d8dcaaf86e09e505fba30f545
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.*; public class Debug { private static Scanner in =new Scanner(System.in); public static void main(String[] args) { int n=in.nextInt(); double k=in.nextInt(); Segement[]z=new Segement[n]; for(int i=0;i<n;i++) z[i]=new Segement(in.nextInt(),in....
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
0b85592a2aa4875c91e551e9366ea50b
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
/** * @(#)PoloThePernguinAndSegments.java * * * @author * @version 1.00 2017/6/23 */ import java.util.*; public class PoloThePernguinAndSegments { public static void main(String[] args) { // TODO code application logic here Scanner in=new Scanner(System.in); int start...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
804a61af0ef55aa2e257608a62e17022
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.*; import java.io.*; //267630EY public class Main289A { static PrintWriter out=new PrintWriter(System.out); public static void main(String[] args) throws IOException { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); int sum=0; for(int i=0;i<n;i...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
a445bb3ba01f4d4183a0a70ea99b120e
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), k = in.nextInt(); long r = 0; while (n-- != 0) { r += -(in.nextInt() - in.nextInt()); r++; } if(r%k != 0) System.out.println(k-r%k); else System.out...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
2bdd3c68f98096ae25d5cd7a63cf57cd
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), k = in.nextInt(); int r = 0; while (n-- != 0) { r += -(in.nextInt() - in.nextInt()); r++; } if(r%k != 0) System.out.println(k-r%k); else System.out....
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
18012f97135b91e594f4d404d8e689c6
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
//package codeforces.A; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class PoloThePenguinAndSegments { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
ca479ebe0fcd997652490eafc5356158
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class CF289A { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int k = s.nextInt(); int value = 0; for (int i = 0; i < n; i++) { int l = s.nextInt(); int r =s.nextInt(); if((r-l)==1) { value+=2; }else { v...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
c99923512a6a28f30a974ba08c7cb2ab
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
//package Div2A; import java.util.Scanner; public class PolothePenguinandSegments { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int left[] = new int[n]; int right[] = new int[n]; int ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
6a699af78d3f5af9f64954faf366532b
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class A289 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int K = in.nextInt(); long sum = 0; for (int n=0; n<N; n++) { int L = in.nextInt(); int R = in.nextInt()...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
1d7b27e36760582181d7554a55fbdeb6
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Ideone { public static void main (String[] args) throws java.lang.Exception { int n, k, interval=0; Scanner input = new Scanner(System.in); n = input.nextInt(); k = input.nextInt(); for(int i=0; i<n; i++) { int start = input....
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
707ca026b186809cbeb6105ae578ee2e
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = Syste...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
058f5d8268af0341ee1e842e975bcc6d
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int covered = 0; int n = sc.nextInt(); int k = sc.nextInt(); for (int i = 0; i < n; i++) { int start = sc.nextInt(); int end ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
2bff9f66d28e7db4680256e1aa83d59c
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
public class Problem { public static void main(String[] args) { java.util.Scanner input = new java.util.Scanner(System.in); long n = input.nextInt(); long k = input.nextInt(); long sum = 2*n , f , s; for (int i = 0 ; i < n ; i++ ){ f = input.nextLong() ; s = inpu...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
baa41c7bf9d59ef72569d0892bd17cc8
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.*; import java.util.*; public class A { public static void main(String[] args) throws Exception { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); Scanner s = new Scanner(System.in); String[] split = f.readLine().split("\...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
35ec396e8ccde125347f6892690d1c99
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class Segments { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); int n = keyboard.nextInt(); int k = keyboard.nextInt(); int value = 0; for (int i = 0; i < n; i++) { int a = keyboard.nextInt...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
72d92ec4d2a887285895f6d811e9100f
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.*; public class Code { public static void main(String[] argh) { Scanner input = new Scanner(System.in); int n = input.nextInt(), k = input.nextInt(); int set_value = 0; for (int i = 0; i < n; i++) { int l = input.nextInt(); int r = input.ne...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
dad26fa7224e3a1b36ce4079cfc75f6d
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class GGWPLivaem implements Runnable{ boolean withFiles = false; class cc implements Comparable<cc>{ public int x, y; cc(int x, int y) { this.x = x; this.y = y; } public int compareTo(cc oth...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
ad53264b3f152373486f37599914ffd3
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.Map; import java.util.Map.Entry; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int l=sc.nextInt(); boolean adi=false; int ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
acfd269046a3c83ee471393f719597aa
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class CF289_D2_A { public static void main(String[] args) { // time reading 5 min // think 1 min // implement time 6 min // debug 0 min Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int k = scanner.nextI...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
1b0906f8a3bc08ea14ff9f76f445605d
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class A289 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStream...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
7ab04b52edd3a55125c8b5402ca3add6
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class PoloThePenguinAndSegments { public static void main(String[] args) { Scanner input = new Scanner (System.in); int n = input.nextInt(); int k = input.nextInt(); int total = 0 ; for (int i = 0 ; ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
f0fe8bd0ea35a751ef6b9cbd6a2fd7a3
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nex...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
8f6f0c5c52b3600436d409a525457225
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class PolothePenguin { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int n = input.nextInt(); int k = input.nextInt(); long total=0; for(int i=0; i<n;i++){ int l = input.nextInt(); int r = input...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
6900325328253bf01092eba5d399a458
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.*; import java.util.*; public class PoloThePenguinAndSegments { public static void main(String[] args) { FastReader sc=new FastReader(); int n=sc.nextInt(); int k=sc.nextInt(); int s=0; for(int i=0;i<n;i++){ s+=-sc.nextInt()+sc.nextInt()+1; } if(s%k==0)System.out.print(0); else Syste...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
b4ae3ed688e3e88653da66096dc4c375
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.*; import java.awt.Desktop; import java.io.*; import java.math.BigInteger; import java.net.URI; import javafx.util.Pair; public class codeforces { /*help fun*/ static boolean prime(long a) { for(int i=2;i*i<=a;i++) { if(a%i==0) return ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
f364c7fc5169d585ce2c89ecbd2deb95
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class Main { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n=ni(),k=ni(); int l=0,r=0; int ans=0; for(int i=0;i<n;++i) { l=ni();...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
083709bc1dc692dbf06797e51077c600
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Abood2B { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); Print...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
36e8387287bb9e27b75a538874cfdd6f
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class PoloThePenguinAndSegments { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), k = sc.nextInt(), x = 0; for (int i = 0; i < n; i++) { int r = sc.nextInt(), l = sc.nextInt(); x += Math.abs(l - r) + 1; } int mod = x...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
423d5bb2b79c7cf1540df9f315f87e99
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; public class PoloThePenguinAndSegments { public static void main (String... args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int k = scanner.nextInt(); int total=0; while (n-- > 0){ int start = scanner.nextInt(...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
f96f0e882e18fba6eb5759561e7c7b0a
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
import java.util.Scanner; import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class TestClass //implements Runnable { /*int x,y; public TestClass(int x,int y) { this.x=x; this.y=y; }*/ public static void main(String args[]) throws Exception {/...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
224f44a3657bea9d028ba14f2a0826c0
train_001.jsonl
1364916600
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the ri...
256 megabytes
// package Virtual289; import java.util.Scanner; public class V289A { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int k = s.nextInt(); int sum = 0; for (int i = 0; i < n; i++) { int left = s.nextInt(); ...
Java
["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7"]
2 seconds
["2", "0"]
null
Java 8
standard input
[ "implementation", "brute force" ]
3a93a6f78b41cbb43c616f20beee288d
The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i &lt; j ≤ n) the following inequ...
1,100
In a single line print a single integer — the answer to the problem.
standard output
PASSED
ee988465f3f092dde90fac9e688f72e2
train_001.jsonl
1349105400
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out)...
Java
["3\n4 5 6"]
2 seconds
["YES\nNO\nNO"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
Java 7
standard input
[ "binary search", "number theory", "implementation", "math" ]
6cebf9af5cfbb949f22e8b336bf07044
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
1,300
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
standard output
PASSED
0909a101125f4de54125692c9f0fe944
train_001.jsonl
1349105400
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class TPrimes { public static void main(String[] args) throws IOException { int l = 1000000; int [] cribaEratostenes = new int[l]; for (int i = 1; i < l; i++) { if (c...
Java
["3\n4 5 6"]
2 seconds
["YES\nNO\nNO"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
Java 7
standard input
[ "binary search", "number theory", "implementation", "math" ]
6cebf9af5cfbb949f22e8b336bf07044
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
1,300
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
standard output
PASSED
e2364b3bc9ce1aa8b59771f4fd4d0a39
train_001.jsonl
1349105400
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class TPrimes { public static void main(String[] args) throws IOException { int l = 1000000; int [] criba = new int[l]; for (int i=1;i<l;i++) { if (criba[i] == 0) ...
Java
["3\n4 5 6"]
2 seconds
["YES\nNO\nNO"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
Java 7
standard input
[ "binary search", "number theory", "implementation", "math" ]
6cebf9af5cfbb949f22e8b336bf07044
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
1,300
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
standard output
PASSED
b5a2a09399b99c4336d5216116348564
train_001.jsonl
1349105400
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.InputMismatchException; public class TPrimes { public static void main(String[] args) { Inpu...
Java
["3\n4 5 6"]
2 seconds
["YES\nNO\nNO"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
Java 7
standard input
[ "binary search", "number theory", "implementation", "math" ]
6cebf9af5cfbb949f22e8b336bf07044
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
1,300
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
standard output
PASSED
c9586451e0c5493b4210dfdf2d82d163
train_001.jsonl
1349105400
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.StringTokenizer; ///////////////////////////////////////////////////////////////////////////////////////////////////////////...
Java
["3\n4 5 6"]
2 seconds
["YES\nNO\nNO"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
Java 7
standard input
[ "binary search", "number theory", "implementation", "math" ]
6cebf9af5cfbb949f22e8b336bf07044
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
1,300
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
standard output
PASSED
763472f4a251774435a2b93604c5ecfa
train_001.jsonl
1349105400
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
256 megabytes
import java.util.HashSet; import java.util.Scanner; public class TPrimes { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); boolean[] np = new boolean[1000009]; np[0] = np[1] = true; for (int i = 2; i * i < np.length; i...
Java
["3\n4 5 6"]
2 seconds
["YES\nNO\nNO"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
Java 7
standard input
[ "binary search", "number theory", "implementation", "math" ]
6cebf9af5cfbb949f22e8b336bf07044
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
1,300
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
standard output
PASSED
e4d9c4ef34a372990deea71b576b5dc2
train_001.jsonl
1349105400
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
256 megabytes
import java.io.*; import java.util.*; public class TPrimes { static ArrayList<Integer> list; static BitSet bset; static int MAX; public static void sieve() { list = new ArrayList<Integer>(); list.add(2); MAX = 1000050; bset = new BitSet(MAX); bset.set(2); for (int j...
Java
["3\n4 5 6"]
2 seconds
["YES\nNO\nNO"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
Java 7
standard input
[ "binary search", "number theory", "implementation", "math" ]
6cebf9af5cfbb949f22e8b336bf07044
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
1,300
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
standard output
PASSED
a00a613917253553c7844747cba7fbaf
train_001.jsonl
1349105400
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
256 megabytes
import java.io.*; import java.security.SecureRandom; import java.util.*; import java.math.*; import java.awt.geom.*; import static java.lang.Math.*; public class cf230b_tPrimes2 implements Runnable { boolean isPrime(long n) { if (n == 1) return false; for (int i = 2;i * i <= ...
Java
["3\n4 5 6"]
2 seconds
["YES\nNO\nNO"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
Java 7
standard input
[ "binary search", "number theory", "implementation", "math" ]
6cebf9af5cfbb949f22e8b336bf07044
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
1,300
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
standard output
PASSED
13fe9640aab914d924613aadee183173
train_001.jsonl
1349105400
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
256 megabytes
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** *cf230b_tPrimes * @author zulkan */ import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.Lis...
Java
["3\n4 5 6"]
2 seconds
["YES\nNO\nNO"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
Java 7
standard input
[ "binary search", "number theory", "implementation", "math" ]
6cebf9af5cfbb949f22e8b336bf07044
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
1,300
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
standard output
PASSED
f31140c6be2d6aeb5d273eedd8dee653
train_001.jsonl
1349105400
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class Tprimes{ static PrintWriter out; boolean [] primes = new boolean [1000000+10]; public Tprimes () throws IOException{ primes[0] = primes [1] = true ; for (int i = 0 ; i < 1000 ; i++ ){ if (!primes[i]){ for (int j = i*i ; j <= 1000000 ; j+= i)...
Java
["3\n4 5 6"]
2 seconds
["YES\nNO\nNO"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
Java 7
standard input
[ "binary search", "number theory", "implementation", "math" ]
6cebf9af5cfbb949f22e8b336bf07044
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
1,300
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
standard output
PASSED
236a10d0b245b5768ec93ca505dc5315
train_001.jsonl
1349105400
We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static int size = 1000000; public static boolean isPrime[] = new boolean[size + 1]; public static void sieve() { Arrays.fill(isPrime, true); isPrime[0] = isPrime[1] = false; for (int i = 2; i * i <= size; i++) { if (isPrime[i]) ...
Java
["3\n4 5 6"]
2 seconds
["YES\nNO\nNO"]
NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".
Java 7
standard input
[ "binary search", "number theory", "implementation", "math" ]
6cebf9af5cfbb949f22e8b336bf07044
The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d spec...
1,300
Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.
standard output
PASSED
66cd80f53ce03ff7d67b7ad47a075152
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.util.*; import java.io.*; public class main { public static void main(String[] args){ FastReader scan = new FastReader(); int t = scan.nextInt(); while(t>0){ t--; int n = scan.nextInt(); int[] arr =new int[n]; ...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
c4f05d839bc44e757daff54f90511b4a
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.util.Scanner; public class MainOne { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int c = 0; c < t; c++) { int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); ...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
88253df00674ade865f3d83266b7a0fb
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.io.IOException; import java.util.Scanner; public class Solution { static int [] arr ; public static void main(String [] args) throws IOException{ Scanner sc = new Scanner(System.in); int t = Integer.parseInt(sc.nextLine()); StringBuilder result = new StringBuilder(); ...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
52a28ae2499353e150cfe9305be6b170
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.util.Scanner; import java.util.Arrays; public class contest2491{ static Scanner scan = new Scanner(System.in); static int t = scan.nextInt(); public static void main(String[] args){ for(int k=0; k<t; k++){ int n = scan.nextInt(); int[] arr = new int[n]; for(int i=0; i<n; i++){ arr[i]=scan....
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
0758e05646fd8c50d29ab6c0efbd42e5
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
/* Wheatley decided to try to make a test chamber. He made a nice test chamber, but there was only one detail absent � cubes. For completing the chamber Wheatley needs n cubes. i-th cube has a volume ai. Wheatley has to place cubes in such a way that they would be sorted in a non-decreasing order by their volume. F...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
38123cccd8e5f12a9deb78aa3f8d11d7
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.util.*; public class CubeSorting { public static void main (String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while(t>0) { int n = scanner.nextInt(); //No. of cubes int[] cubes = new int[n]; int[] arr = new int [n]; for(int i = 0...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
a62e815f895636dbac72c9e437786498
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
//package CodeForces; import java.util.ArrayList; import java.util.Queue; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.LinkedList; import java.util.Scanner; import java.util.Stack; public class ValueOfAnExpressio...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
759113cfb9e41be223eb8ff086b7b34c
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.*; public class TestP { public static void main(String[] args) throws Exception{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); for(int t = Integer.parseInt(reader.readLine()); t > 0; t--) { int n = Integer.pars...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
9c95117f3141d1bd259a524ad19b3743
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { // Scanner sc = new Scanner(System.in); FastScanner sc = new FastScanner(); PrintWriter ou...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
a64b6843edac9c2de43d6b3dc2555be2
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { // Scanner sc = new Scanner(System.in); FastScanner sc = new FastScanner(); PrintWriter ou...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
1a3d0eb1f072992bd8c0ca84a579e75e
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.util.*; import java.math.BigInteger; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); int arr[] = new int[n...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
2455ee4eca95b5b8a4369a01d99f6bc6
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.util.*; import java.math.BigInteger; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); int count = 0; int arr[...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
ff8c21ad736f6a8dc1b79b21583d215b
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; public class FibinacciSeries { static class FastReader { BufferedReader br; StringTokenizer st; public FastR...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
f571a9e5bdbd01568e144e9f1652d2b8
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.List; import java.math.BigInteger; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.Set; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; ...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
c51bcdb384a4b48da7c926a7db7dc481
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.util.*; public class sol { public static void main(String[] args) { //BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i+...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
699db448d9955c6546358b4db1e1179b
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int T = in.nextInt(); for(int tt=0;tt<T;tt++) { int n = in.nextInt(); int[] a=new int[n]; int[] sort...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
4be8e6b0f37c2bea7feffb1c25fb43e5
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.util.Scanner; public class CubesSorting { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc....
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
c3835e8b57534dc83e3a8ec63890da0e
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[]args) { Scanner s=new Scanner(System.in); int op=s.nextInt(); while(op>0) { int n=s.nextI...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
dacdcd6b0286c6b88f1733134d301c82
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.util.*; import java.io.*; public class Cubes_Sorting_672A { static int mod = (int) (1e9 + 7); public static void main(String[] args) throws java.lang.Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while (t-- > 0) { ...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
8d5b58820470d5972aad83294b6e8b3d
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.util.*; import java.io.*; public class Election { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ long n=sc.nextInt(); long c2=n*(n-1)/2-1; int max=0; long count=0; ...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
b393e610ad39f52cdb66a6591b4dedb6
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
// Don't place your source in a package import java.util.*; import java.lang.*; import java.io.*; import java.math.*; // Please name your class Main public class Main { static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static int read() throws IOExce...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
cb266903516a04be69f123aa41be5b05
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.util.*; public class t{ public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ boolean can=false; int n=sc.nextInt(); int [] arr=new int[n]; for(int i=0;i<n;i++) {arr[i]=sc.nextInt();} for(int i=1;i<n;i++){ ...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
5edce7b5e849bace026457199db1d5fb
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; public class Abc { public static void main(String[] args) { FastScanner fs = new FastScanner(); int t=fs.nextInt(); while(t-->0) { int n =fs....
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
d7c7adfc3169e37b80134efd1e63bce0
train_001.jsonl
1600958100
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got ...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; 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...
Java
["3\n5\n5 3 2 1 4\n6\n2 2 2 2 2 2\n2\n2 1"]
1 second
["YES\nYES\nNO"]
NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".
Java 8
standard input
[ "sortings", "math" ]
b34f29e6fb586c22fa1b9e559c5a6c50
Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The ...
900
For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.
standard output
PASSED
8c5558bd065e71de553defbc2cde610e
train_001.jsonl
1595601300
The length of the longest common prefix of two strings $$$s = s_1 s_2 \ldots s_n$$$ and $$$t = t_1 t_2 \ldots t_m$$$ is defined as the maximum integer $$$k$$$ ($$$0 \le k \le min(n,m)$$$) such that $$$s_1 s_2 \ldots s_k$$$ equals $$$t_1 t_2 \ldots t_k$$$.Koa the Koala initially has $$$n+1$$$ strings $$$s_1, s_2, \dots,...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class demo_A{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); char ch [] = new char[200]; Arrays.fill(ch, 'a'); while( t-- > 0 ){ int n = sc.nex...
Java
["4\n4\n1 2 4 2\n2\n5 3\n3\n1 3 1\n3\n0 0 0"]
1 second
["aeren\nari\narousal\naround\nari\nmonogon\nmonogamy\nmonthly\nkevinvu\nkuroni\nkurioni\nkorone\nanton\nloves\nadhoc\nproblems"]
NoteIn the $$$1$$$-st test case one of the possible answers is $$$s = [aeren, ari, arousal, around, ari]$$$.Lengths of longest common prefixes are: Between $$$\color{red}{a}eren$$$ and $$$\color{red}{a}ri$$$ $$$\rightarrow 1$$$ Between $$$\color{red}{ar}i$$$ and $$$\color{red}{ar}ousal$$$ $$$\rightarrow 2$$$ Between...
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
6983823efdc512f8759203460cd6bb4c
Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the list $$$a$$$. The second line of e...
1,200
For each test case: Output $$$n+1$$$ lines. In the $$$i$$$-th line print string $$$s_i$$$ ($$$1 \le |s_i| \le 200$$$), consisting of lowercase Latin letters. Length of the longest common prefix of strings $$$s_i$$$ and $$$s_{i+1}$$$ has to be equal to $$$a_i$$$. If there are many answers print any. We can show that ans...
standard output
PASSED
9da0b40b684a5bcbf3ef97b21aa1a1ed
train_001.jsonl
1595601300
The length of the longest common prefix of two strings $$$s = s_1 s_2 \ldots s_n$$$ and $$$t = t_1 t_2 \ldots t_m$$$ is defined as the maximum integer $$$k$$$ ($$$0 \le k \le min(n,m)$$$) such that $$$s_1 s_2 \ldots s_k$$$ equals $$$t_1 t_2 \ldots t_k$$$.Koa the Koala initially has $$$n+1$$$ strings $$$s_1, s_2, \dots,...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { public static void main (String[] args) throws java.lang.Exception { BufferedWriter log = new Buffer...
Java
["4\n4\n1 2 4 2\n2\n5 3\n3\n1 3 1\n3\n0 0 0"]
1 second
["aeren\nari\narousal\naround\nari\nmonogon\nmonogamy\nmonthly\nkevinvu\nkuroni\nkurioni\nkorone\nanton\nloves\nadhoc\nproblems"]
NoteIn the $$$1$$$-st test case one of the possible answers is $$$s = [aeren, ari, arousal, around, ari]$$$.Lengths of longest common prefixes are: Between $$$\color{red}{a}eren$$$ and $$$\color{red}{a}ri$$$ $$$\rightarrow 1$$$ Between $$$\color{red}{ar}i$$$ and $$$\color{red}{ar}ousal$$$ $$$\rightarrow 2$$$ Between...
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
6983823efdc512f8759203460cd6bb4c
Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the list $$$a$$$. The second line of e...
1,200
For each test case: Output $$$n+1$$$ lines. In the $$$i$$$-th line print string $$$s_i$$$ ($$$1 \le |s_i| \le 200$$$), consisting of lowercase Latin letters. Length of the longest common prefix of strings $$$s_i$$$ and $$$s_{i+1}$$$ has to be equal to $$$a_i$$$. If there are many answers print any. We can show that ans...
standard output
PASSED
d77ea08aa7334a09d4b80bf89dab6a16
train_001.jsonl
1595601300
The length of the longest common prefix of two strings $$$s = s_1 s_2 \ldots s_n$$$ and $$$t = t_1 t_2 \ldots t_m$$$ is defined as the maximum integer $$$k$$$ ($$$0 \le k \le min(n,m)$$$) such that $$$s_1 s_2 \ldots s_k$$$ equals $$$t_1 t_2 \ldots t_k$$$.Koa the Koala initially has $$$n+1$$$ strings $$$s_1, s_2, \dots,...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main{ static class Reader{ BufferedReader br; StringTokenizer st; Reader(){ br = new BufferedReader(new InputStreamReader(System.in)); } ...
Java
["4\n4\n1 2 4 2\n2\n5 3\n3\n1 3 1\n3\n0 0 0"]
1 second
["aeren\nari\narousal\naround\nari\nmonogon\nmonogamy\nmonthly\nkevinvu\nkuroni\nkurioni\nkorone\nanton\nloves\nadhoc\nproblems"]
NoteIn the $$$1$$$-st test case one of the possible answers is $$$s = [aeren, ari, arousal, around, ari]$$$.Lengths of longest common prefixes are: Between $$$\color{red}{a}eren$$$ and $$$\color{red}{a}ri$$$ $$$\rightarrow 1$$$ Between $$$\color{red}{ar}i$$$ and $$$\color{red}{ar}ousal$$$ $$$\rightarrow 2$$$ Between...
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
6983823efdc512f8759203460cd6bb4c
Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the list $$$a$$$. The second line of e...
1,200
For each test case: Output $$$n+1$$$ lines. In the $$$i$$$-th line print string $$$s_i$$$ ($$$1 \le |s_i| \le 200$$$), consisting of lowercase Latin letters. Length of the longest common prefix of strings $$$s_i$$$ and $$$s_{i+1}$$$ has to be equal to $$$a_i$$$. If there are many answers print any. We can show that ans...
standard output
PASSED
08fae0deaeb55fe81e30e9ea287dcc1c
train_001.jsonl
1595601300
The length of the longest common prefix of two strings $$$s = s_1 s_2 \ldots s_n$$$ and $$$t = t_1 t_2 \ldots t_m$$$ is defined as the maximum integer $$$k$$$ ($$$0 \le k \le min(n,m)$$$) such that $$$s_1 s_2 \ldots s_k$$$ equals $$$t_1 t_2 \ldots t_k$$$.Koa the Koala initially has $$$n+1$$$ strings $$$s_1, s_2, \dots,...
256 megabytes
import java.io.PrintWriter; import java.util.*; public class Main { static boolean inversed; static int l = 0; static int n; static int id1, id2; public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int...
Java
["4\n4\n1 2 4 2\n2\n5 3\n3\n1 3 1\n3\n0 0 0"]
1 second
["aeren\nari\narousal\naround\nari\nmonogon\nmonogamy\nmonthly\nkevinvu\nkuroni\nkurioni\nkorone\nanton\nloves\nadhoc\nproblems"]
NoteIn the $$$1$$$-st test case one of the possible answers is $$$s = [aeren, ari, arousal, around, ari]$$$.Lengths of longest common prefixes are: Between $$$\color{red}{a}eren$$$ and $$$\color{red}{a}ri$$$ $$$\rightarrow 1$$$ Between $$$\color{red}{ar}i$$$ and $$$\color{red}{ar}ousal$$$ $$$\rightarrow 2$$$ Between...
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
6983823efdc512f8759203460cd6bb4c
Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the list $$$a$$$. The second line of e...
1,200
For each test case: Output $$$n+1$$$ lines. In the $$$i$$$-th line print string $$$s_i$$$ ($$$1 \le |s_i| \le 200$$$), consisting of lowercase Latin letters. Length of the longest common prefix of strings $$$s_i$$$ and $$$s_{i+1}$$$ has to be equal to $$$a_i$$$. If there are many answers print any. We can show that ans...
standard output
PASSED
216ce2f2d1cbe76105eeaaa7d65a48eb
train_001.jsonl
1595601300
The length of the longest common prefix of two strings $$$s = s_1 s_2 \ldots s_n$$$ and $$$t = t_1 t_2 \ldots t_m$$$ is defined as the maximum integer $$$k$$$ ($$$0 \le k \le min(n,m)$$$) such that $$$s_1 s_2 \ldots s_k$$$ equals $$$t_1 t_2 \ldots t_k$$$.Koa the Koala initially has $$$n+1$$$ strings $$$s_1, s_2, \dots,...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package Div2_659; import java.util.Arrays; import java.util.Scanner; /** * * @author HP */ public class Main { public static...
Java
["4\n4\n1 2 4 2\n2\n5 3\n3\n1 3 1\n3\n0 0 0"]
1 second
["aeren\nari\narousal\naround\nari\nmonogon\nmonogamy\nmonthly\nkevinvu\nkuroni\nkurioni\nkorone\nanton\nloves\nadhoc\nproblems"]
NoteIn the $$$1$$$-st test case one of the possible answers is $$$s = [aeren, ari, arousal, around, ari]$$$.Lengths of longest common prefixes are: Between $$$\color{red}{a}eren$$$ and $$$\color{red}{a}ri$$$ $$$\rightarrow 1$$$ Between $$$\color{red}{ar}i$$$ and $$$\color{red}{ar}ousal$$$ $$$\rightarrow 2$$$ Between...
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
6983823efdc512f8759203460cd6bb4c
Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the list $$$a$$$. The second line of e...
1,200
For each test case: Output $$$n+1$$$ lines. In the $$$i$$$-th line print string $$$s_i$$$ ($$$1 \le |s_i| \le 200$$$), consisting of lowercase Latin letters. Length of the longest common prefix of strings $$$s_i$$$ and $$$s_{i+1}$$$ has to be equal to $$$a_i$$$. If there are many answers print any. We can show that ans...
standard output
PASSED
d15617c7298c589e91ed7757e4f01baf
train_001.jsonl
1595601300
The length of the longest common prefix of two strings $$$s = s_1 s_2 \ldots s_n$$$ and $$$t = t_1 t_2 \ldots t_m$$$ is defined as the maximum integer $$$k$$$ ($$$0 \le k \le min(n,m)$$$) such that $$$s_1 s_2 \ldots s_k$$$ equals $$$t_1 t_2 \ldots t_k$$$.Koa the Koala initially has $$$n+1$$$ strings $$$s_1, s_2, \dots,...
256 megabytes
//package round_659_div2; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class A { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(br.readLine()); whil...
Java
["4\n4\n1 2 4 2\n2\n5 3\n3\n1 3 1\n3\n0 0 0"]
1 second
["aeren\nari\narousal\naround\nari\nmonogon\nmonogamy\nmonthly\nkevinvu\nkuroni\nkurioni\nkorone\nanton\nloves\nadhoc\nproblems"]
NoteIn the $$$1$$$-st test case one of the possible answers is $$$s = [aeren, ari, arousal, around, ari]$$$.Lengths of longest common prefixes are: Between $$$\color{red}{a}eren$$$ and $$$\color{red}{a}ri$$$ $$$\rightarrow 1$$$ Between $$$\color{red}{ar}i$$$ and $$$\color{red}{ar}ousal$$$ $$$\rightarrow 2$$$ Between...
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
6983823efdc512f8759203460cd6bb4c
Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the list $$$a$$$. The second line of e...
1,200
For each test case: Output $$$n+1$$$ lines. In the $$$i$$$-th line print string $$$s_i$$$ ($$$1 \le |s_i| \le 200$$$), consisting of lowercase Latin letters. Length of the longest common prefix of strings $$$s_i$$$ and $$$s_{i+1}$$$ has to be equal to $$$a_i$$$. If there are many answers print any. We can show that ans...
standard output
PASSED
341d7485d8fdfd95b0732ac79578dfc5
train_001.jsonl
1595601300
The length of the longest common prefix of two strings $$$s = s_1 s_2 \ldots s_n$$$ and $$$t = t_1 t_2 \ldots t_m$$$ is defined as the maximum integer $$$k$$$ ($$$0 \le k \le min(n,m)$$$) such that $$$s_1 s_2 \ldots s_k$$$ equals $$$t_1 t_2 \ldots t_k$$$.Koa the Koala initially has $$$n+1$$$ strings $$$s_1, s_2, \dots,...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collections; import java.util.List; public class A { public static void main(String[] args) throws IOException { BufferedReader br = new Buffer...
Java
["4\n4\n1 2 4 2\n2\n5 3\n3\n1 3 1\n3\n0 0 0"]
1 second
["aeren\nari\narousal\naround\nari\nmonogon\nmonogamy\nmonthly\nkevinvu\nkuroni\nkurioni\nkorone\nanton\nloves\nadhoc\nproblems"]
NoteIn the $$$1$$$-st test case one of the possible answers is $$$s = [aeren, ari, arousal, around, ari]$$$.Lengths of longest common prefixes are: Between $$$\color{red}{a}eren$$$ and $$$\color{red}{a}ri$$$ $$$\rightarrow 1$$$ Between $$$\color{red}{ar}i$$$ and $$$\color{red}{ar}ousal$$$ $$$\rightarrow 2$$$ Between...
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
6983823efdc512f8759203460cd6bb4c
Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the list $$$a$$$. The second line of e...
1,200
For each test case: Output $$$n+1$$$ lines. In the $$$i$$$-th line print string $$$s_i$$$ ($$$1 \le |s_i| \le 200$$$), consisting of lowercase Latin letters. Length of the longest common prefix of strings $$$s_i$$$ and $$$s_{i+1}$$$ has to be equal to $$$a_i$$$. If there are many answers print any. We can show that ans...
standard output
PASSED
16a4715684e87012eb1eb6a61c48c9a5
train_001.jsonl
1595601300
The length of the longest common prefix of two strings $$$s = s_1 s_2 \ldots s_n$$$ and $$$t = t_1 t_2 \ldots t_m$$$ is defined as the maximum integer $$$k$$$ ($$$0 \le k \le min(n,m)$$$) such that $$$s_1 s_2 \ldots s_k$$$ equals $$$t_1 t_2 \ldots t_k$$$.Koa the Koala initially has $$$n+1$$$ strings $$$s_1, s_2, \dots,...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class A659 { public static void func(int n, int arr[]){ int count = 1; int max = arr[0]; for (int i = 0; i < n; i++) max = Math.max(max, arr[i]); if (max == 0) max = 10; StringBuilder sb = new StringBuilder(); ...
Java
["4\n4\n1 2 4 2\n2\n5 3\n3\n1 3 1\n3\n0 0 0"]
1 second
["aeren\nari\narousal\naround\nari\nmonogon\nmonogamy\nmonthly\nkevinvu\nkuroni\nkurioni\nkorone\nanton\nloves\nadhoc\nproblems"]
NoteIn the $$$1$$$-st test case one of the possible answers is $$$s = [aeren, ari, arousal, around, ari]$$$.Lengths of longest common prefixes are: Between $$$\color{red}{a}eren$$$ and $$$\color{red}{a}ri$$$ $$$\rightarrow 1$$$ Between $$$\color{red}{ar}i$$$ and $$$\color{red}{ar}ousal$$$ $$$\rightarrow 2$$$ Between...
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
6983823efdc512f8759203460cd6bb4c
Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the list $$$a$$$. The second line of e...
1,200
For each test case: Output $$$n+1$$$ lines. In the $$$i$$$-th line print string $$$s_i$$$ ($$$1 \le |s_i| \le 200$$$), consisting of lowercase Latin letters. Length of the longest common prefix of strings $$$s_i$$$ and $$$s_{i+1}$$$ has to be equal to $$$a_i$$$. If there are many answers print any. We can show that ans...
standard output
PASSED
64099a80e9af1a0d1913342d135087ff
train_001.jsonl
1595601300
The length of the longest common prefix of two strings $$$s = s_1 s_2 \ldots s_n$$$ and $$$t = t_1 t_2 \ldots t_m$$$ is defined as the maximum integer $$$k$$$ ($$$0 \le k \le min(n,m)$$$) such that $$$s_1 s_2 \ldots s_k$$$ equals $$$t_1 t_2 \ldots t_k$$$.Koa the Koala initially has $$$n+1$$$ strings $$$s_1, s_2, \dots,...
256 megabytes
import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.PriorityQueue; import java.uti...
Java
["4\n4\n1 2 4 2\n2\n5 3\n3\n1 3 1\n3\n0 0 0"]
1 second
["aeren\nari\narousal\naround\nari\nmonogon\nmonogamy\nmonthly\nkevinvu\nkuroni\nkurioni\nkorone\nanton\nloves\nadhoc\nproblems"]
NoteIn the $$$1$$$-st test case one of the possible answers is $$$s = [aeren, ari, arousal, around, ari]$$$.Lengths of longest common prefixes are: Between $$$\color{red}{a}eren$$$ and $$$\color{red}{a}ri$$$ $$$\rightarrow 1$$$ Between $$$\color{red}{ar}i$$$ and $$$\color{red}{ar}ousal$$$ $$$\rightarrow 2$$$ Between...
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
6983823efdc512f8759203460cd6bb4c
Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the list $$$a$$$. The second line of e...
1,200
For each test case: Output $$$n+1$$$ lines. In the $$$i$$$-th line print string $$$s_i$$$ ($$$1 \le |s_i| \le 200$$$), consisting of lowercase Latin letters. Length of the longest common prefix of strings $$$s_i$$$ and $$$s_{i+1}$$$ has to be equal to $$$a_i$$$. If there are many answers print any. We can show that ans...
standard output
PASSED
54feb40bb9831fdea5a5febed1e0c1c7
train_001.jsonl
1595601300
The length of the longest common prefix of two strings $$$s = s_1 s_2 \ldots s_n$$$ and $$$t = t_1 t_2 \ldots t_m$$$ is defined as the maximum integer $$$k$$$ ($$$0 \le k \le min(n,m)$$$) such that $$$s_1 s_2 \ldots s_k$$$ equals $$$t_1 t_2 \ldots t_k$$$.Koa the Koala initially has $$$n+1$$$ strings $$$s_1, s_2, \dots,...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class CodeForces{ public static void main(String args[])throws IOException{ Scanner in=new Scanner(System.in); int T=in.nextInt(); while(T-->0){ int n=in.nextInt(); int a[]=new int[n]; int max=0; f...
Java
["4\n4\n1 2 4 2\n2\n5 3\n3\n1 3 1\n3\n0 0 0"]
1 second
["aeren\nari\narousal\naround\nari\nmonogon\nmonogamy\nmonthly\nkevinvu\nkuroni\nkurioni\nkorone\nanton\nloves\nadhoc\nproblems"]
NoteIn the $$$1$$$-st test case one of the possible answers is $$$s = [aeren, ari, arousal, around, ari]$$$.Lengths of longest common prefixes are: Between $$$\color{red}{a}eren$$$ and $$$\color{red}{a}ri$$$ $$$\rightarrow 1$$$ Between $$$\color{red}{ar}i$$$ and $$$\color{red}{ar}ousal$$$ $$$\rightarrow 2$$$ Between...
Java 8
standard input
[ "constructive algorithms", "greedy", "strings" ]
6983823efdc512f8759203460cd6bb4c
Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the list $$$a$$$. The second line of e...
1,200
For each test case: Output $$$n+1$$$ lines. In the $$$i$$$-th line print string $$$s_i$$$ ($$$1 \le |s_i| \le 200$$$), consisting of lowercase Latin letters. Length of the longest common prefix of strings $$$s_i$$$ and $$$s_{i+1}$$$ has to be equal to $$$a_i$$$. If there are many answers print any. We can show that ans...
standard output