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
79dae96c669dc7b4bb778f5f7d19addb
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.InputMismatchException; /** * Created by assalielmehdi on 8/15/17. */ public class CF469_D2_B { private InputReader in; private PrintWriter out; private StringBuilder sb; private boolean onlineJudge = System.getProperty("ONLINE_JUDGE") != nu...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai < bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj < dj ≤ 1000). It's guaranteed that bi < ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
25cc7d5382b6b0793140481953c04318
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.Scanner; import java.util.*; public class abdelmagied { public static class pair{ int first , second; pair(int first ,int second){ this.first = first; this.second = second; } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int p = sc.nextInt(); ...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai < bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj < dj ≤ 1000). It's guaranteed that bi < ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
fe8e5a93f875a38e0683ec2f25a955c5
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.Scanner; public class ChatOnline { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int p = sc.nextInt(); int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int[][] z = new int[p][2]; for (int i ...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai < bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj < dj ≤ 1000). It's guaranteed that bi < ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
25d019650355e50e218cbb70d797c0d0
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.*; public class Chat { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int p = sc.nextInt(); int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int a[] = new int[p]; int b[] = new int[p]; i...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai < bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj < dj ≤ 1000). It's guaranteed that bi < ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
2ecf5c45375eb0d149ebee5762040161
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.*; public class Chat { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int p = sc.nextInt(); int q = sc.nextInt(); int l = sc.nextInt(); int r = sc.nextInt(); int a[] = new int[p]; int b[] = new int[p]; i...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai < bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj < dj ≤ 1000). It's guaranteed that bi < ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
ed690e4150a260ceacfe8e322cccaf65
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.Scanner; public class Chat_Online { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int p = s.nextInt(); int q = s.nextInt(); int l = s.nextInt(); int r = s.nextInt(); boolean visited_a[] = new boolean[1001]; boolean vis...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai < bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj < dj ≤ 1000). It's guaranteed that bi < ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
a5f5386499627d9513163aee77bbd3c5
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.io.*; import java.util.*; public class d { static ArrayList<Integer>[]g; public static void main(String args[]) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader sc = new InputReader(inputStream); PrintWriter...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
fa2205e4995d7d41a5dc1243c6a929dc
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.io.*; import java.util.*; public class ChatOnline { static class os { int s, e; public os(int s, int e) { this.s = s; this.e = e; } } public static void main(String[] args) { Scanner in = new Scanner(System.in); int q = in.nex...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
43f8dbaa7ced9102f38674a7b75c256b
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.io.*; import java.util.*; public class ChatOnline { static class os { int s,e; public os(int s, int e) { this.s = s; this.e = e; } } public static void main(String[] args) { Scanner in = new Scanner(System.in); int q = in.nextInt(); ...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
08e65dc8a9fd079d4281002ab39c293e
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader br...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
bca470b7e57d6c18bdf9b5b8c56028b1
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class test { int max = 0; long max1 = 0; boolean visited[][]; int parent[]; boolean bi=true; StringBuilder cout=new StringBuilder(""); int color[]; PrintStream out = System.out; int signx[] = {1,-1,0 ,0, 1, ...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
03a6633a33d57902cbc2e5671a6c9af4
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.*; import java.io.*; public class Main469B { static PrintWriter out=new PrintWriter(System.out); public static void main(String[] args) throws IOException { Scanner sc=new Scanner(System.in); int p=sc.nextInt(); int q=sc.nextInt(); int l=sc.nextInt(); int r=sc.nextInt(); ...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
91658e0fc145c3c31a80a767de5dadd5
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.*; import java.io.*; //267630EY public class Main469B2 { static PrintWriter out=new PrintWriter(System.out); public static void main(String[] args) throws IOException { Scanner sc=new Scanner(System.in); int p=sc.nextInt(); int q=sc.nextInt(); int l=sc.nextInt(); int r=s...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
51e741cbe53db8f7fc0f4a011ad35d39
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int p = s.nextInt(); int q = s.nextInt(); int l = s.nextInt(); int r = s.nextInt(); int[] a = new int[p]; int[] b = new int[p]; int[] c = new...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
da7bbd56589d91458ad2085bc9429b2c
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import sun.nio.cs.ext.MacHebrew; import java.util.*; public class Student { private static Scanner input = new Scanner(System.in); public static void main(String[] args) { int n= input.nextInt(); int m= input.nextInt(); int l= input.nextInt(); int r= input.nextInt(); boo...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
b40176a18ef2958e9cf2dbea352d2702
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner in = new Scanner(System.in); String input = in.nextLine(); String[] split = input.split(" "); int p = Integer.parseInt(split[0]); int q = Integer....
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
0efcfab958a7a15d0a33319a9fea3e8e
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.*; public class Solution { public static void main(String args[]) { Scanner input = new Scanner(System.in); int p,q,l,r; int counter = 0; p = input.nextInt(); q = input.nextInt(); l = input.nextInt(); r = input.nextInt(); int[] fixed = new int[1001]; int[] temp; int[][] free = ne...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
cbdffec2838dae9ace6f39c65e0029f4
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import static java.lang.Math.*; import java.math.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System....
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
610a44b3088506f9bfc099daee4073f4
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Main{ public static void main(String[] args) { FastScanner sc =new FastScanner(); PrintWriter out=new PrintWriter(System.out); int n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt(),r=sc.nextInt(); Set<Integer> set =ne...
Java
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
8661adbec70e0b6b34e76ea3f4a95d9e
train_002.jsonl
1411218000
Little X and Little Z are good friends. They always chat online. But both of them have schedules.Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time...
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
["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17"]
1 second
["3", "20"]
null
Java 8
standard input
[ "implementation" ]
aa77158bf4c0854624ddd89aa8b424b3
The first line contains four space-separated integers p, q, l, r (1 ≤  p, q ≤ 50;Ā 0 ≤ l ≤ r ≤ 1000). Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai &lt; bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj &lt; dj ≤ 1000). It's guaranteed that bi &lt; ...
1,300
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
standard output
PASSED
af487b4e8bb91a0703e43eea4706b199
train_002.jsonl
1565188500
The subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.You are given an integer $$$n$$$. You have to find a sequence $$$s$$$ consisting of digits $$$\{1, 3, 7\}$$$ such that it has exactly $$$n$$$ subsequences equal to $$$13...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; /** * Built using CHelper plug-in * Actual solution is at the top */ public class PrintA1337String { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; ...
Java
["2\n6\n1"]
1 second
["113337\n1337"]
null
Java 11
standard input
[ "combinatorics", "constructive algorithms", "math", "strings" ]
9aabacc9817722dc11335eccac5d65ac
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10$$$) — the number of queries. Next $$$t$$$ lines contains a description of queries: the $$$i$$$-th line contains one integer $$$n_i$$$ ($$$1 \le n_i \le 10^9$$$).
1,900
For the $$$i$$$-th query print one string $$$s_i$$$ ($$$1 \le |s_i| \le 10^5$$$) consisting of digits $$$\{1, 3, 7\}$$$. String $$$s_i$$$ must have exactly $$$n_i$$$ subsequences $$$1337$$$. If there are multiple such strings, print any of them.
standard output
PASSED
396fb427a9641a89041cfe9cb74a024b
train_002.jsonl
1565188500
The subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.You are given an integer $$$n$$$. You have to find a sequence $$$s$$$ consisting of digits $$$\{1, 3, 7\}$$$ such that it has exactly $$$n$$$ subsequences equal to $$$13...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class d { static BufferedReader s = new BufferedReader(new InputStreamReader(System.in)); // static Scanner s=new Scanner(System.in); public static void ma...
Java
["2\n6\n1"]
1 second
["113337\n1337"]
null
Java 11
standard input
[ "combinatorics", "constructive algorithms", "math", "strings" ]
9aabacc9817722dc11335eccac5d65ac
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10$$$) — the number of queries. Next $$$t$$$ lines contains a description of queries: the $$$i$$$-th line contains one integer $$$n_i$$$ ($$$1 \le n_i \le 10^9$$$).
1,900
For the $$$i$$$-th query print one string $$$s_i$$$ ($$$1 \le |s_i| \le 10^5$$$) consisting of digits $$$\{1, 3, 7\}$$$. String $$$s_i$$$ must have exactly $$$n_i$$$ subsequences $$$1337$$$. If there are multiple such strings, print any of them.
standard output
PASSED
5dbffa9af2731d9982265a9f132a6fae
train_002.jsonl
1565188500
The subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.You are given an integer $$$n$$$. You have to find a sequence $$$s$$$ consisting of digits $$$\{1, 3, 7\}$$$ such that it has exactly $$$n$$$ subsequences equal to $$$13...
256 megabytes
import java.io.*; import java.util.*; public class r70p4{ public static void main(String args[])throws IOException{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(reader.readLine()); ...
Java
["2\n6\n1"]
1 second
["113337\n1337"]
null
Java 11
standard input
[ "combinatorics", "constructive algorithms", "math", "strings" ]
9aabacc9817722dc11335eccac5d65ac
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10$$$) — the number of queries. Next $$$t$$$ lines contains a description of queries: the $$$i$$$-th line contains one integer $$$n_i$$$ ($$$1 \le n_i \le 10^9$$$).
1,900
For the $$$i$$$-th query print one string $$$s_i$$$ ($$$1 \le |s_i| \le 10^5$$$) consisting of digits $$$\{1, 3, 7\}$$$. String $$$s_i$$$ must have exactly $$$n_i$$$ subsequences $$$1337$$$. If there are multiple such strings, print any of them.
standard output
PASSED
7332a716fc45f6aee018868f1a216c1e
train_002.jsonl
1565188500
The subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.You are given an integer $$$n$$$. You have to find a sequence $$$s$$$ consisting of digits $$$\{1, 3, 7\}$$$ such that it has exactly $$$n$$$ subsequences equal to $$$13...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; // 9:18.049 public class cf1202d { public static void main(String[] args) throws IOException { int t = ri(); while (t --> 0) { List<Integer> threes = new ArrayList<>(); ...
Java
["2\n6\n1"]
1 second
["113337\n1337"]
null
Java 11
standard input
[ "combinatorics", "constructive algorithms", "math", "strings" ]
9aabacc9817722dc11335eccac5d65ac
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10$$$) — the number of queries. Next $$$t$$$ lines contains a description of queries: the $$$i$$$-th line contains one integer $$$n_i$$$ ($$$1 \le n_i \le 10^9$$$).
1,900
For the $$$i$$$-th query print one string $$$s_i$$$ ($$$1 \le |s_i| \le 10^5$$$) consisting of digits $$$\{1, 3, 7\}$$$. String $$$s_i$$$ must have exactly $$$n_i$$$ subsequences $$$1337$$$. If there are multiple such strings, print any of them.
standard output
PASSED
c3fb08182ab206be66decfc2c731c41b
train_002.jsonl
1565188500
The subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.You are given an integer $$$n$$$. You have to find a sequence $$$s$$$ consisting of digits $$$\{1, 3, 7\}$$$ such that it has exactly $$$n$$$ subsequences equal to $$$13...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * ...
Java
["2\n6\n1"]
1 second
["113337\n1337"]
null
Java 11
standard input
[ "combinatorics", "constructive algorithms", "math", "strings" ]
9aabacc9817722dc11335eccac5d65ac
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10$$$) — the number of queries. Next $$$t$$$ lines contains a description of queries: the $$$i$$$-th line contains one integer $$$n_i$$$ ($$$1 \le n_i \le 10^9$$$).
1,900
For the $$$i$$$-th query print one string $$$s_i$$$ ($$$1 \le |s_i| \le 10^5$$$) consisting of digits $$$\{1, 3, 7\}$$$. String $$$s_i$$$ must have exactly $$$n_i$$$ subsequences $$$1337$$$. If there are multiple such strings, print any of them.
standard output
PASSED
2ffb5732921421772e7475b75da08022
train_002.jsonl
1565188500
The subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.You are given an integer $$$n$$$. You have to find a sequence $$$s$$$ consisting of digits $$$\{1, 3, 7\}$$$ such that it has exactly $$$n$$$ subsequences equal to $$$13...
256 megabytes
import java.util.*; import java.io.*; public class D70 { static ArrayList<Integer> ret; public static void main(String[] args) { MyScanner sc = new MyScanner(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int t = sc.nextInt(); while (t > 0) { ...
Java
["2\n6\n1"]
1 second
["113337\n1337"]
null
Java 11
standard input
[ "combinatorics", "constructive algorithms", "math", "strings" ]
9aabacc9817722dc11335eccac5d65ac
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10$$$) — the number of queries. Next $$$t$$$ lines contains a description of queries: the $$$i$$$-th line contains one integer $$$n_i$$$ ($$$1 \le n_i \le 10^9$$$).
1,900
For the $$$i$$$-th query print one string $$$s_i$$$ ($$$1 \le |s_i| \le 10^5$$$) consisting of digits $$$\{1, 3, 7\}$$$. String $$$s_i$$$ must have exactly $$$n_i$$$ subsequences $$$1337$$$. If there are multiple such strings, print any of them.
standard output
PASSED
f172e98b662201074571b7ebe7c53350
train_002.jsonl
1338132600
In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number n. During the walk it is allowed to move from ...
256 megabytes
/** * Created with IntelliJ IDEA. * User: Zakhar_Voit * Date: 28.05.12 * Time: 1:52 */ import java.io.*; import java.util.*; import static java.lang.System.exit; public class B { BufferedReader in; PrintWriter out; StringTokenizer st = new StringTokenizer(""); int n, ans = 0; int[] a; v...
Java
["4\n10 3 5 10", "5\n10 2 8 3 5"]
2 seconds
["5", "5"]
NoteIn the first sample the second tile gets destroyed after day three, and the only path left is 1 → 3 → 4. After day five there is a two-tile gap between the first and the last tile, you can't jump over it.In the second sample path 1 → 3 → 5 is available up to day five, inclusive. On day six the last tile is destroye...
Java 7
standard input
[ "implementation", "brute force" ]
d526af933b5afe9abfdf9815e9664144
The first line contains integer n (1 ≤ n ≤ 103) — the boulevard's length in tiles. The second line contains n space-separated integers ai — the number of days after which the i-th tile gets destroyed (1 ≤ ai ≤ 103).
1,100
Print a single number — the sought number of days.
standard output
PASSED
f419431f60413af069e14087c2f9a022
train_002.jsonl
1338132600
In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number n. During the walk it is allowed to move from ...
256 megabytes
import java.util.*; public class WalkingInTheRain { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; ++i) { a[i] = in.nextInt(); } int time = 0; while (true) { if (a[0] - time <= 0 || a[n - 1] ...
Java
["4\n10 3 5 10", "5\n10 2 8 3 5"]
2 seconds
["5", "5"]
NoteIn the first sample the second tile gets destroyed after day three, and the only path left is 1 → 3 → 4. After day five there is a two-tile gap between the first and the last tile, you can't jump over it.In the second sample path 1 → 3 → 5 is available up to day five, inclusive. On day six the last tile is destroye...
Java 7
standard input
[ "implementation", "brute force" ]
d526af933b5afe9abfdf9815e9664144
The first line contains integer n (1 ≤ n ≤ 103) — the boulevard's length in tiles. The second line contains n space-separated integers ai — the number of days after which the i-th tile gets destroyed (1 ≤ ai ≤ 103).
1,100
Print a single number — the sought number of days.
standard output
PASSED
cf6322877a553c10f5f2727a238d7ebb
train_002.jsonl
1338132600
In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number n. During the walk it is allowed to move from ...
256 megabytes
import java.io.*; import java.util.*; public class TaskB implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer stok; String nextToken() { try { while (stok == null || !stok.hasMoreTokens()) { stok = new StringTokenizer(in.readLine()); } } catch (Exception e) { return null; }...
Java
["4\n10 3 5 10", "5\n10 2 8 3 5"]
2 seconds
["5", "5"]
NoteIn the first sample the second tile gets destroyed after day three, and the only path left is 1 → 3 → 4. After day five there is a two-tile gap between the first and the last tile, you can't jump over it.In the second sample path 1 → 3 → 5 is available up to day five, inclusive. On day six the last tile is destroye...
Java 7
standard input
[ "implementation", "brute force" ]
d526af933b5afe9abfdf9815e9664144
The first line contains integer n (1 ≤ n ≤ 103) — the boulevard's length in tiles. The second line contains n space-separated integers ai — the number of days after which the i-th tile gets destroyed (1 ≤ ai ≤ 103).
1,100
Print a single number — the sought number of days.
standard output
PASSED
6bfed82b9b7adb7d37a3ae6e74ded0ba
train_002.jsonl
1338132600
In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number n. During the walk it is allowed to move from ...
256 megabytes
import java.awt.Point; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.math.BigInteger; import static java.math.BigInteger.*; import java.io.*; import java.security.PublicKey; import java.util.*; public class Main { void solve()throws Exception { int n = nextInt(); int []a...
Java
["4\n10 3 5 10", "5\n10 2 8 3 5"]
2 seconds
["5", "5"]
NoteIn the first sample the second tile gets destroyed after day three, and the only path left is 1 → 3 → 4. After day five there is a two-tile gap between the first and the last tile, you can't jump over it.In the second sample path 1 → 3 → 5 is available up to day five, inclusive. On day six the last tile is destroye...
Java 7
standard input
[ "implementation", "brute force" ]
d526af933b5afe9abfdf9815e9664144
The first line contains integer n (1 ≤ n ≤ 103) — the boulevard's length in tiles. The second line contains n space-separated integers ai — the number of days after which the i-th tile gets destroyed (1 ≤ ai ≤ 103).
1,100
Print a single number — the sought number of days.
standard output
PASSED
6be8b10d259900e4a100054895841cb2
train_002.jsonl
1338132600
In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number n. During the walk it is allowed to move from ...
256 megabytes
import java.util.Scanner; public class B_192_Walking_in_the_Rain { public static void main(String[] args){ Scanner input=new Scanner(System.in); int n=input.nextInt(); int[] days=new int[n]; int i,j; for(i=0;i<n;i++) days[i]=input.nextInt(); int min=1000; int tmp; outer: for(i=0;i<n;i++){ if(d...
Java
["4\n10 3 5 10", "5\n10 2 8 3 5"]
2 seconds
["5", "5"]
NoteIn the first sample the second tile gets destroyed after day three, and the only path left is 1 → 3 → 4. After day five there is a two-tile gap between the first and the last tile, you can't jump over it.In the second sample path 1 → 3 → 5 is available up to day five, inclusive. On day six the last tile is destroye...
Java 7
standard input
[ "implementation", "brute force" ]
d526af933b5afe9abfdf9815e9664144
The first line contains integer n (1 ≤ n ≤ 103) — the boulevard's length in tiles. The second line contains n space-separated integers ai — the number of days after which the i-th tile gets destroyed (1 ≤ ai ≤ 103).
1,100
Print a single number — the sought number of days.
standard output
PASSED
d1405e34627bf09f6f844e75c86ddad8
train_002.jsonl
1338132600
In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number n. During the walk it is allowed to move from ...
256 megabytes
import java.util.Scanner; import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author codeKNIGHT */ public class Main { public static void main(String[] args) { InputStream inputStrea...
Java
["4\n10 3 5 10", "5\n10 2 8 3 5"]
2 seconds
["5", "5"]
NoteIn the first sample the second tile gets destroyed after day three, and the only path left is 1 → 3 → 4. After day five there is a two-tile gap between the first and the last tile, you can't jump over it.In the second sample path 1 → 3 → 5 is available up to day five, inclusive. On day six the last tile is destroye...
Java 7
standard input
[ "implementation", "brute force" ]
d526af933b5afe9abfdf9815e9664144
The first line contains integer n (1 ≤ n ≤ 103) — the boulevard's length in tiles. The second line contains n space-separated integers ai — the number of days after which the i-th tile gets destroyed (1 ≤ ai ≤ 103).
1,100
Print a single number — the sought number of days.
standard output
PASSED
6f8c3c42033d50f96266ec7403d6bbbb
train_002.jsonl
1338132600
In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number n. During the walk it is allowed to move from ...
256 megabytes
import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Iterator; pu...
Java
["4\n10 3 5 10", "5\n10 2 8 3 5"]
2 seconds
["5", "5"]
NoteIn the first sample the second tile gets destroyed after day three, and the only path left is 1 → 3 → 4. After day five there is a two-tile gap between the first and the last tile, you can't jump over it.In the second sample path 1 → 3 → 5 is available up to day five, inclusive. On day six the last tile is destroye...
Java 7
standard input
[ "implementation", "brute force" ]
d526af933b5afe9abfdf9815e9664144
The first line contains integer n (1 ≤ n ≤ 103) — the boulevard's length in tiles. The second line contains n space-separated integers ai — the number of days after which the i-th tile gets destroyed (1 ≤ ai ≤ 103).
1,100
Print a single number — the sought number of days.
standard output
PASSED
ba2a5dd792b0e30092fdf751400ac875
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class C { FastScanner in; PrintWriter out; public void run() { //System.out.println((int)'a'); try { in = new FastScanner(new InputStr...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
2145f4d5b97a3d4be3c4b786769628c4
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); ...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
4cd37ceebee706687f303dc083fcb408
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.util.Scanner; public class TestC { public static void main (String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int p = sc.nextInt(); String s = sc.next(); int k =s.length(); int end_abc = 97+p; char[] slovo = s.toCharArra...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
ccae76d02396d50ac9794349efb0ade4
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.util.Scanner; public class p3 { public static void main(String[] ar4gs) { new p3().start(); } int p; public void start() { Scanner in=new Scanner(System.in); int n=in.nextInt(); p=in.nextInt(); p+=97; in.nextLine(); String s=in.nextLine(); byte[] arr=s.getBytes(); if(inc(arr,arr....
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
f605ec7dd0d04cf8d63a213623dfb486
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.util.Scanner; import java.io.PrintStream; import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inpu...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
9612be5a1cac6a474805638f734d5b45
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String args[]) throws NumberFormatException, IOException { Stdin in = new Stdin(); PrintWriter out = new Print...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
aa51a725319c119098547cd7d829b9ff
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); final int MOD = 1000000007; int[] dx = { 1, -1, 1, -1 }; int[] dy = { 1, 1, -1, -1 }; void run() { int n = sc.nextInt(); int p = sc.nextInt(); char max = (char) ('a'...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
4d9b03867bc2aa4ce1a84dba79fdbb1d
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class MainC { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy = { 0, 1, -1, 0 }; void run() { int n = sc.nextInt(); int p = sc.nextInt(); char max = (char) ('a' ...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
d4dbf5a18b9dc1ca634b205e9177e746
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); final int MOD = 1000000007; int[] dx = { 1, -1, 1, -1 }; int[] dy = { 1, 1, -1, -1 }; void run() { int n = sc.nextInt(); int p = sc.nextInt(); char max = (char) ('a'...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
42b63dc57095ae9fb7ef08229804b614
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); final int MOD = 1000000007; int[] dx = { 1, -1, 1, -1 }; int[] dy = { 1, 1, -1, -1 }; void run() { int n = sc.nextInt(); int p = sc.nextInt(); char max = (char) ('a'...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
5b36e14aa052555b7b252b36eda327f6
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.io.BufferedInputStream; import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; public class Main { //public static final int C = 1000000007; //static BigDecimal map[][]; //static int N; //static int M; public static void m...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
95c066c2e82269c7ca145ec35825abc0
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.StringToke...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
cef607f80cef608a4e58197370e67f5e
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.util.Scanner; import java.io.PrintStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author about@manhquynh.net */ public class Main { public static void main(Stri...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
082bacf8934afa814d1e2a47d90058e3
train_002.jsonl
1410103800
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable stri...
256 megabytes
import java.util.Scanner; public class NoPalindromes { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int p = sc.nextInt(); String s = sc.next(); char[] chars = s.toCharArray(); int[] nums = new int[chars.length]; ...
Java
["3 3\ncba", "3 4\ncba", "4 4\nabcd"]
1 second
["NO", "cbd", "abda"]
NoteString s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti, si + 1 &gt; ti + 1.The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.A palindrome is a str...
Java 7
standard input
[ "brute force" ]
788ae500235ca7b7a7cd320f745d1070
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
1,700
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
standard output
PASSED
5cdede82ce4f54ff6ed572c7e7916aff
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigI...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
d24e0f8247667ae3d73cafe70c7cc5bb
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigI...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
35c8babdd315aeef1c18bb461e2c035b
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { static BufferedReader in; static PrintWriter out; public static long getAi(long A, long B, long index) { return A + (index-1)*B; } public static long getSum(long A, l...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
15691596fc6ba7fb8060e5b4d3f7a8a4
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
//535C import java.util.Scanner; public class TavasAndKarafs { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int n = sc.nextInt(); for (int _ = 0; _ < n; _++) { int l = sc.nextInt(); int t = sc.nextInt(); int m = sc.nex...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
4a69eb97e61a963252f799ec7f797873
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
//package codeforces.cfr299div2; import java.util.Scanner; /** * Created by bistrashkin on 4/14/15. */ public class C { private static boolean canEat(long A, long B, long l, long m, long t, long r) { long count = r - l + 1; long first = A + B * (l - 1); long last = A + B * (r - 1); ...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
c04deac2869afeaf44fba74531ff5657
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.*; import java.util.LinkedList; import java.util.StringTokenizer; public class C{ static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReade...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
e337437991f2fa21163f95e1f963aa3e
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.util.Scanner; public class TavasKafas { public static void main(String[] agrs) { Scanner in = new Scanner(System.in); int a = in.nextInt(); int b = in.nextInt(); int n = in.nextInt(); for (int i = 0; i < n; i++) { int l = in.nextInt(); int t = in.nextInt(); int m = i...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
edaab108e0398964bc98e708a629e9ec
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Stack; import java.util.StringTokenizer; public class Main { static FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
96869bf518d3e3182f6778b9cef44649
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.util.*; import java.io.*; public class Main { BufferedReader in; StringTokenizer str = null; PrintWriter out; private String next() throws Exception{ while (str == null || !str.hasMoreElements()) str = new StringTokenizer(in.readLine()); return str.nextToken(); } private int nextInt() thr...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
ee491a3ae705c0939192d1fc9c7ed1e2
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public stat...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
5168d9b91df39e39bd8aaad92fa0f713
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void main(String[] args) throws Exception { int dex = 0; FastScanner qwe = new FastScanner(System.in); long A = qwe.nextLong(); long B = qwe.nextLong(); int n = qwe.nextInt(); PrintWriter out = new PrintWriter(System.out); w...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
e03e2986345e1e02ac3c4a299261b5b2
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class TavasAndKarafs { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String [] input = br.readLine().split(" "); lon...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
838c4df9d92b2b57b575c9e17fe90b3a
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static MyScanner in; static PrintWriter out; //static Timer t = new Timer(); public static void main(String[] args) throws IOException { in = new MyScanner(); out = new PrintWriter(System.out); long a = in.nextInt(), b...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
1fe22fd9db3209ac391bafa710674d1a
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.IOException; import java.util.InputMismatchException; import java.util.Scanner; public class c299_3 { public static void main(String args[]){ Scanner s=new Scanner(System.in); int A=s.nextInt(); int B=s.nextInt(); int n=s.nextInt(); long v[]=new long[10000000]; long s1[]=new...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
3a1245bade452dce8f8bad31c8273f17
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
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; import java.util.TreeSet; public class D { static IR in = new IR(System.in); static long A,B; static int q; static long l,t,m; sta...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
7aa2c0cf17dba94bcf48df377561c565
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String [] args)throws Exception{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(br.readLine()); int a=Integer.parseInt(st.nextToken()); int b=Integer.parseInt(st.ne...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
02694bd6dc3687886363fc1f5a519709
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.util.*; public class Solution { static long ans=-1; static long sent=(long)Math.pow(10,12); static void BinarySearch(int a,int b,long low, long high, long x,int left,int m,long vleft) { if(low > high){ return ; } long mid = (low+high)/2; long val...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
f8f91af892645f85ef3a14d31615f05e
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Comparator; import java.util.PriorityQueue; public class hals { static long bs (long l,long start , long end,long t,long m,long a,long b){ long lo=l,hi=end,mid=0,curr,sum; while(lo<hi){ mid= lo + (hi-lo)/2; curr = (mid-1)*b+a;...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
e9d82213fdbe7c5741ebcc10f9baad5a
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Map; imp...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
f5c3413a1022dea5b55285f99e17cb94
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.Random; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; im...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
7e856ce16e83b3802038a2b5c9571314
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.util.*; import java.io.*; public class C { public static void main(String[] args) throws FileNotFoundException { new C().solve(); } public void solve() throws FileNotFoundException { Scanner in = new Scanner(System.in); int a = in.nextInt(); int b = in.nextInt()...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
0ffe4e62d77055066640d04937228a1c
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; // http://codeforces.com/contest/535/problem/C public class C { public static void main(String[] args) throws IOException { try (BufferedReader in = new BufferedReader(new InputStreamReade...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
0d4e7a2f97e118b12def7c4d69c40fc3
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; @SuppressWarnings("javadoc") public class TavasAndKarafs { public TavasAndKarafs() throws IOException { BufferedReader br = new BufferedReader(new InputStre...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
16850fce973364d2f2f48949a99e3a2a
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; @SuppressWarnings("javadoc") public class TavasAndKarafs { public TavasAndKarafs() throws IOException { BufferedReader br = new BufferedReader(new InputStre...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
aed9c7174a1861d762dc6f3415452a28
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; @SuppressWarnings("javadoc") public class TavasAndKarafs { public TavasAndKarafs() throws IOException { BufferedReader br = new BufferedReader(new InputStre...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
5a9baceb7bb871e3c17152aa639361f5
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) throws IOException { // System.out // .println(getElementLessOrEqualThanTAndGreaterThanL(1, 13, 3, 5)); // System.out...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
79bb23fc7fb52c8a8f0a5253f280ad0a
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.PrintStream; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; ...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
7d8e23a75ba879e7c22712595c31b326
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces { static long arr[]; static long sum[]; public static void main(String[] args) throws IOException { Reader.init(System.in); int a = Reader.nextInt(); long b = Reader.nextInt(); int n = Reader.nextInt(); ...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
15ee04e99d4d86a821efe930cb63875a
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.*; import java.util.*; public final class xor_equation { static FastScanner sc=new FastScanner(new BufferedReader(new InputStreamReader(System.in))); static PrintWriter out=new PrintWriter(System.out); public static void main(String args[]) throws Exception { long a=sc.nextLong(),b=sc.nextL...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
03bfd939b91480c9a533edda57a6168f
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.*; import java.util.*; public class Karafs { public static void main(String[]args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int A = Integer.parseInt(st.nextToken());...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
39db79b4c2e369b20bf4142f14b35b67
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.*; import java.util.*; public class Karafs { public static void main(String[]args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int A = Integer.parseInt(st.nextToken());...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
a3d3b90990567a030b2568ee409d9f9e
train_002.jsonl
1429029300
Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the i-th Karafs is si = A + ...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import jav...
Java
["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4"]
2 seconds
["4\n-1\n8\n-1", "1\n2"]
null
Java 7
standard input
[ "binary search", "greedy", "math" ]
89c97b6c302bbb51e9d5328c680a7ea7
The first line of input contains three integers A, B and n (1 ≤ A, B ≤ 106, 1 ≤ n ≤ 105). Next n lines contain information about queries. i-th line contains integers l, t, m (1 ≤ l, t, m ≤ 106) for i-th query.
1,900
For each query, print its answer in a single line.
standard output
PASSED
71dffa1a8929052a471ad42564a44ea7
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0) { int n = sc.nextInt(); int k = sc.nextInt(); long ar[] = new long[n]; ...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
6b961b9022a35205177f78a9478d50cd
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.io.*; import java.util.Objects; import java.util.StringTokenizer; import static java.lang.Double.parseDouble; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.System.exit; public class Solution { static BufferedReader in; static PrintWrite...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
9d7b3240faf7be158dfe750b0f5588ab
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.util.Scanner; public class Problem1341Bprototype { public static void main(String[] args) { Scanner object = new Scanner(System.in); int pares = object.nextInt(); for(int i = 0; i < pares; i++) { int countHill = object.nextInt(), doorLength = object.nextInt(); int hills[] = new int[countHill...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
5e7cc4bcd63477c07a92fd7e852070a4
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.io.*; public class Solution{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); while(t-->0){ String[]in=br.readLine().split(" "); int n=Integer.parseInt(in[0]),k=Integer.parse...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
f78a84f1ab8f07087cb21f413d69e5cb
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Scanner; public class main { public static ArrayList<Long> list = new ArrayList<Long>(); private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
cc2ecd1162b6b3a825857e622716eaa6
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.io.*; import java.util.*; import java.util.Map.Entry; public class Nastya_and_Door { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputS...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
0be21e42781c0615c3f25635809320ea
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Solve { FastScanner in; PrintWriter out; void solve() { int T = in.nextInt(); while (0 < T--) { int n = in.nextInt(); int k = in.nextInt(); int[] a = new int[n]; for (int ...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
a160343d1229edd2c89f85a9cb784524
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Solve { FastScanner in; PrintWriter out; void solve() { int T = in.nextInt(); while (0 < T--) { int n = in.nextInt(); int k = in.nextInt(); int[] a = in.nextIntArray(n); ...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
b19c0721bff42e433941c297e44d3fba
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class A { FastScanner in; PrintWriter out; void solve() { int T = in.nextInt(); while (0 < T--) { int n = in.nextInt(); int k = in.nextInt(); int[] a = new int[n+1]; for (int i ...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
07097e1a3fa044215b491e1041f53a07
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class A { FastScanner in; PrintWriter out; void solve() { int T = in.nextInt(); while (0 < T--) { int n = in.nextInt(); int k = in.nextInt(); int[] h = new int[n]; for (int i = ...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
aaeb1e5689af05d0e8f24fa2628be481
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
/** * @author derrick20 */ import java.io.*; import java.util.*; public class NatsyaDoor { public static void main(String[] args) throws Exception { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int T = sc.nextInt(); while (T-->0) { ...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
d4938dfd80b4bc1a760199741ca0f1e4
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.InputMismatchException; public class A { public static void main(String[] args) throws Exception { // TODO Auto-generated method stub InputReader s = new InputReader(System.in); Prin...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
18d911a7c6be89cae166f6a4870c97f9
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.InputMismatchException; public class A { public static void main(String[] args) throws Exception { // TODO Auto-generated method stub InputReader s = new InputReader(System.in); Print...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
8ca916992dc234525e6fdd1bba6f94cc
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
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.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
6dc957fc05eed3eb33b0fe05bb62f2d7
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.io.InputStreamReader; import java.util.*; import java.io.*; public class q2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int test = Integer.parseInt(br.readLine()); while(test-->0){ ...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
06befa8f88ce4538c1de2bd6166f40b2
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.*; public class Solution { public static void dfs(int arr[][],boolean[] v,int n,int h ){ v[h]=true; boolean child=false; for(int i=0;i<n;i++){ ...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
294134c06780755c80c5be3c4bd5099b
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.util.*; import java.lang.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); while(t-->0) { int n = scan.nextInt(); int k = scan.nextInt(); int [] a = new int[n]; int ans = 0; int l = 1; ...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
3db6d03ef9988fdeb2a3b4d4301f5842
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.util.*; import java.lang.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); while(t-->0) { int n = scan.nextInt(); int k = scan.nextInt(); int [] a = new int[n]; int ans = 0; //the number of pea...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
17d4bd1cbb4e857f0a39c6fc602c6dcb
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.util.*; import java.lang.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); while(t-->0) { int n = scan.nextInt(); int k = scan.nextInt(); int [] a = new int[n+1]; int ans = 0; int [] p =...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
4db693af907de56a24a75ee0ef071765
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; import java.util.Arrays; /** * @author Alice */ public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner str = new Scanner(System.in); int t = str.nextInt(); whi...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output
PASSED
a90d4124e8f6dabaf0b3d0e88a5af190
train_002.jsonl
1587653100
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequenc...
256 megabytes
import java.io.*; import java.util.*; public class Main { private static boolean isSame(int a, int b) { return (a < 0 && b < 0) || (a > 0 && b > 0); } private static void solve(MyScanner in, PrintWriter out) { int n = in.nextInt(); int k = in.nextInt(); int a[] = new int...
Java
["5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1"]
1 second
["3 2\n2 2\n2 1\n3 1\n2 3"]
NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$...
Java 8
standard input
[ "implementation", "greedy" ]
8e182e0acb621c86901fb94b56ff991e
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. T...
1,300
For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.
standard output