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
85a0e9fd46377736d7cc4c4d1e45a999
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
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.SplittableRandom;import java.util.InputMismatchException;import java.io.IOException;import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
80282c187e013f68f8cc9fddf7e46acc
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
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.SplittableRandom;import java.util.InputMismatchException;import java.io.IOException;import java.io.InputStream;/** * Built using CHelper plug-in * Actual solution is at t...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
804e8fff422c3653cc459f3cc051fb1f
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
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.SplittableRandom; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solu...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
27800f14115dc1e6719a000ed69c4146
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.*; import java.util.*; public class D { FastReader scn; PrintWriter out; String INPUT = ""; void solve() { int n = scn.nextInt(); long k = scn.nextLong(); long[][] pref = new long[n + 1][2]; for (int i = 1; i <= n; i++) { pref[i][0] = pref[i - 1][0] + scn.nextLong(); pref[i][1] = i; ...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
5aaa90bfd12b585cfbd01bd341d9d2a7
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.*; import java.util.*; public class D { FastReader scn; PrintWriter out; String INPUT = ""; void solve() { int n = scn.nextInt(); long k = scn.nextLong(); long[] arr = new long[n + 1]; long[][] pref = new long[n + 1][2]; for (int i = 1; i <= n; i++) { arr[i] = scn.nextLong(); pref[i...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
579ffe404b07f02d772ffc9e43f5a34c
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.*; import java.util.*; public class D { FastReader scn; PrintWriter out; String INPUT = ""; void solve() { int n = scn.nextInt(); long k = scn.nextLong(); long[] arr = new long[n + 1]; long[][] pref = new long[n + 1][2]; for (int i = 1; i <= n; i++) { arr[i] = scn.nextLong(); pref[i...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
b5c6c505a6f668eca9f1eb2c3c378cbd
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; import static java.lang.Math.*; public class Solution{ static long[] tree; static long[] arr,pre,post; static ArrayList<Long>[] al; static long build(int i,int l,int r,long t,int n){ int j; //System.out.println(l+" "+r); if(l==r...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
070b1e5953ef4304f1b91055ed9a31d3
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; public class Main { static class Node { public int height; public long value; public Node parent; public Node leftSon; public Node rightSon; ...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
57577df0956dd89d5f4c12573f1ae106
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; import java.util.Random; import java.util.StringTokenizer; public class Main { String fileName = ""; ////////////////////// SOLUTION SOLUTION SOLUTION ////////////////////////////// Long INF = Long....
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
d68b93a50c3d36a8735e7ff7e2a80f85
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.TreeMap; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelpe...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
187a847edb146007703156e65ef9f949
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class d1042 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); long T = in.nextLong(); long[] arr = new long[N]; for(int n=0;n<N;n++) arr[n] = in.nextLong(); long[] sum = new long[N+1]; for(in...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
136804384442054447d7a4ac0db857d9
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.stream.Stream; /** * @author madi.sagimbekov */ public class C1042D ...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
203d8742f540f1e5babad68a3763a159
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.io.*; import java.util.*; public class D1042 { static int tree[]; public static void main(String args[])throws IOE...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
26687a005c638e6fb902c75c46b98d1b
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) { IO io = new IO(System.in, System.out); int n = io.nextInt(); long t = io.nextLong(); long ans = 0; long sum = 0; SplayTree st = new SplayT...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
a70e534dc0dde1dc5b74e8918f61acaf
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { static long ans = 0; public static void main(String[] args) { IO io = new IO(System.in, System.out); int n = io.nextInt(); long t = io.nextLong(); SplayTree st = new Splay...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
1a2d41a6741d4de66bd065284f3c85b8
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.TreeMap; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExcep...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
9a35d4d2520096901de8839eea694b3d
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.util.*; public class PetyaAndArray { public static void main(String[] args) { Scanner scan=new Scanner(System.in);//damn im bad int n=scan.nextInt(); long t=scan.nextLong(); long[] a=new long[n]; Long[] sorted=new Long[n]; for(int i=0;i<n;i++) { a[i]=scan.nextLong(); if(i!=0) a[i]+=a[i-1...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
123ee985887a0616beeea4af4a0ca02f
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.StringTokenizer; public class D { static final boolean debug=false; public static void main(String[] args) { FastScanner fs=new FastScanner(); int n=fs.nextInt(); long queryS...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
3f5a9b631583aee9e057920f5e52ebdb
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
/** * Date: 27 Sep, 2019 * Link: * * @author Prasad Chaudhari * @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/ * @git: https://github.com/Prasad-Chaudhari */ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import ja...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
3244faceb82cded44bdb8a6b558f3f22
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Random; import java.util.StringTokenizer; public class Main implements ...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
19da331aec02d980c08f65ac49275755
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.util.*; import java.io.*; public class Main { static long[] sorted; static Fenwick tree; public static void main(String[] args) { FastReader reader = new FastReader(); PrintWriter writer = new PrintWriter(System.out); int n = reader.nextInt()+1; long t = reader.nextLong(); long[] a = new ...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
faa72ad5eb15839245616ecd2d37d4f6
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.*; import java.util.*; /** * Copyright © 2018 Chris. All rights reserved. * * @author Chris * 2018/7/9 15:33 * @see format */ public class D { private static BufferedReader br; private static StreamTokenizer st; private static PrintWriter pw; static int[] BT; static int low...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
60ae14dbf85ffd95e967d5a17fd7a471
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
import java.io.InputStreamReader; import java.util.Arrays; import java.io.BufferedReader; import java.io.IOException; public class Main { final static int MAXN = 200010; static int n; static long K; final static long ranl = -200000000000000L, ranr = 200000000000000L; public static class node { node ls, rs; int...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
8cd05d5b36180826d501c7871d70bf2c
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
/* * * @Author Ajudiya_13(Bhargav Girdharbhai Ajudiya) * Dhirubhai Ambani Institute of Information And Communication Technology * */ import java.util.*; import java.io.*; import java.lang.*; public class Code336 { static class SegmentTree { long st[][]; SegmentTree(long[] a,int n) { int x = (i...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
c5b964cebc15724d14a09453211474b3
train_000.jsonl
1537171500
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.Now he wonders what is the number of segments i...
256 megabytes
//package baobab; import java.io.*; import java.util.*; public class D { public static void main(String[] args) { Solver solver = new Solver(); } static class Solver { IO io; public Solver() { this.io = new IO(); try { solve(); ...
Java
["5 4\n5 -1 3 4 -1", "3 0\n-1 2 -3", "4 -1\n-2 1 -2 3"]
2 seconds
["5", "4", "3"]
NoteIn the first example the following segments have sum less than $$$4$$$: $$$[2, 2]$$$, sum of elements is $$$-1$$$ $$$[2, 3]$$$, sum of elements is $$$2$$$ $$$[3, 3]$$$, sum of elements is $$$3$$$ $$$[4, 5]$$$, sum of elements is $$$3$$$ $$$[5, 5]$$$, sum of elements is $$$-1$$$
Java 8
standard input
[ "data structures", "two pointers", "divide and conquer" ]
42c4adc1c4a10cc619c05a842e186e60
The first line contains two integers $$$n$$$ and $$$t$$$ ($$$1 \le n \le 200\,000, |t| \le 2\cdot10^{14}$$$). The second line contains a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$|a_{i}| \le 10^{9}$$$) — the description of Petya's array. Note that there might be negative, zero and positive elements.
1,800
Print the number of segments in Petya's array with the sum of elements less than $$$t$$$.
standard output
PASSED
2780da9517b3c156147f1967ae040557
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.util.*; import java.math.*; import java.text.*; import java.io.*; public class Main{ public static void main(String[] args){ Scanner cin=new Scanner(System.in); int n,a,b; String s; int ans=0; n=cin.nextInt(); a=cin.nextInt(); b=cin.nextInt(); s=cin.next(); //System.out.println(s); i...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
613dfaa91c6d2b0054704d25e309f200
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.util.*; public class Solution{ static int solve(char[] arr, int A, int B) { int abCount = 0; if (A <= 0 && B <= 0) return 0; if (arr[0] != '*') { arr[0] = A > B ? 'a' : 'b'; if (A > B) A--; else B--; abCount++; } for (int i = 1; i < arr.length; i++) { if ...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
6662c60954ac9756f226b278b953a3ed
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; import java.util.ArrayList; import java.util.List; public class Problem2 { private static final char EMPTY = '.'; private static final char NOT_EMPTY = '*'; public static void main(...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
c4463e876d33e32f0a8a7f755df3978b
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; public class cf962b2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int seats = sc.nextInt(); int a = sc.nextInt(); int b =sc.nextInt(); sc.nextLine(); char[] a...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
f8bcbaab11833a24324c6ea01174a62e
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Puneet //FastRead class is ...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
83c784c1278c6abf3aa4a4cfa0cfb102
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
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 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
34f73a2bbc7be9b7bddc2a932904c256
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String[] temp = in.readLine().split(" "); int n = I...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
144403c903e6930e7db96af672d5dca2
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.util.Scanner; public class bProblem { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int a = scan.nextInt(); int b = scan.nextInt(); char[] arr = scan.next().toCharArray(); for(int i = 0;i<n;i++){ if(arr[i] == '*'){ continue; ...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
3bec0de828931453406c7558f30eaa0f
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int a = in.nextInt(); int b = in.nextInt(); String s = in.next(); int count = 0; for (int i = 0; i < s.length()...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
5bad53688dd7e2c51ca0c34bb4d2d6f7
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.io.*; import java.util.stream.Stream; /** * @author madi.sagimbekov */ public class C962B { private static BufferedReader in; private static BufferedWriter out; public static void main(String[] args) throws IOException { open(); int[] x = readInts(); int n = x[0]; ...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
de082a846383dc243207203fbece59f4
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.util.*; public class HelloWorld{ public static void main(String []args){ Scanner in = new Scanner(System.in); in.nextInt(); int na = in.nextInt(); int nb = in.nextInt(); String line = in.next(); int ans = 0; int count = 0; int last = 0; ...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
6dbb195f056a86a3d657a09af3bc69b3
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
//codeforces_962B import java.io.*; import java.util.*; import static java.lang.Math.*; public class acm{ public static void main(String args[]) throws IOException{ BufferedReader gi = new BufferedReader(new InputStreamReader(System.in)); PrintWriter go = new PrintWriter(System.out); String line[] = gi.readLin...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
4ec26c66c0faa05a85dd558033eb3e20
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.util.*; public class RailWay{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int pro = sc.nextInt(); int ath = sc.nextInt(); String pos = sc.next(); char[] seat = pos.toCharArray(); int cnt = 0; if(seat[0] == '.' && pro >...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
91615cc4ebaf350162e24db6c5d44705
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
/** * Date: 10 Apr, 2018 * Link: 962 B * * @author Prasad-Chaudhari * @email prasadc8897@gmail.com */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class newProgram2 { public static void main(String[] args) throws IOException { // TODO code appl...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
78609adf1da6c5a3fe1eedf289b36f6d
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.Scanner; public class B { static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamRead...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
a3102dc26c8ed05514ccd7c72664c096
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.Scanner; public class B { static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamRead...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
4853c0f9840fcb724d21abe19427d404
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String args[]){ Scanner s = new Scanner(System.in); int n = s.nextInt(); int a = s.nextInt(); int b = s.nextInt(); String str = s.next(); char prev = '!'; int c = 0; for(int i=0;i<n...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
074debb1b12fc3f22c7ed66c0d6ec2df
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.io.*; import java.util.*; import java.math.BigInteger; public class Main { private static StringBuilder sb = new StringBuilder(); private static void s(String s){ System.out.print(s); } private static void s(Double s){ System.out.print(s); } private static void s(char...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
d3f74460d4dd223c17f3e4ae7df04abb
train_000.jsonl
1523370900
There are $$$n$$$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of $$$a$$$ student-programmers and $$$b$$$ student-athletes. Determine the largest number of students from all $$$a+b$$$ students, which you can put in the...
256 megabytes
import java.util.Scanner; public class abc { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char c=' '; int n=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt(),t=0;sc.nextLine(); String s=sc.nextLine(); if(s.charAt(0) =='.' && b<=a && a!=0 ) { a--;t++;c='a';} else ...
Java
["5 1 1\n*...*", "6 2 3\n*...*.", "11 3 10\n.*....**.*.", "3 2 3\n***"]
2 seconds
["2", "4", "7", "0"]
NoteIn the first example you can put all student, for example, in the following way: *.AB*In the second example you can put four students, for example, in the following way: *BAB*BIn the third example you can put seven students, for example, in the following way: B*ABAB**A*BThe letter A means a student-programmer, and ...
Java 8
standard input
[ "constructive algorithms", "implementation", "greedy" ]
6208dbdf9567b759b0026db4af4545a9
The first line contain three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n \le 2\cdot10^{5}$$$, $$$0 \le a, b \le 2\cdot10^{5}$$$, $$$a + b &gt; 0$$$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with l...
1,300
Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete.
standard output
PASSED
fb439663f00cd01b7fc2f512773dc247
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; public class MainS { static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000_000L; static final int INf = 1_000_000_000; static FastReader reader; static PrintWriter writer; public static void main(String[] args) { ...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
02c9932aed2841a3176e0752e546757a
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
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
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
9700ef76152ad4addd96a7de29c66665
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.PriorityQueue; import java.util.StringTokenizer; public class Main { public static boolean check(long numdays, long d1, long d2, char[] Arr) { long n=nu...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
1662aa6aeeb5c1e2ff914254c6e960dc
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.PriorityQueue; import java.util.StringTokenizer; public class Main { static class pair { long acc1; long acc2; public pair(long d1, long d2) { t...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
e7f9e0d227cdcee198655a2c48b952b1
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.util.*; public class C1117 { public static void main(String[] args) { Scanner in = new Scanner(System.in); long xo = in.nextInt(); long yo = in.nextInt(); long xf = in.nextInt(); long yf = in.nextInt(); int l = in.nextInt(); int[] dx = new int[l]; int[] dy = new int[l]; int sx = 0; int...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
d19cfb1c3fc4fa53403b431c30b56fbe
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author real */ public class Main ...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
637168252539c6e22b0f80e3db9be920
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper p...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
fb427fa56d88b44293c813f22d131c12
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.util.*; import java.io.*; import java.util.regex.*; public class Codeforces{ static class MyScanner{ BufferedReader br; StringTokenizer st; MyScanner(FileReader fileReader){ br = new BufferedReader(fileReader); } MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
f3b754d9c49e1498668095d012dda24d
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.util.Objects; import java.nio.charset.Charset; import java.util....
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
da56cf96208ae1e342b8ce8cff3279a4
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.TreeSet; public class E60C { public static void main(String[] args) { JS scan = new JS(); TreeSet<Long> worked = new TreeSet<>(); long x1 = s...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
ad6d3b8e6c0baa7f4b53e905fefd1b4a
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.util.*; import org.omg.CORBA.Principal; import java.awt.List; import java.io.*; import java.lang.*; public class c1 { public static long mod = (long) Math.pow(10, 9) + 7; public static InputReader in = new InputReader(System.in); public static PrintWriter pw = new PrintWriter(System.out); public sta...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
c7d02b6b9755f7a5b29a539aa015de74
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.*; import java.util.*; public class Main { public void solve() { int x1 = ni(), y1 = ni(), x2 = ni(), y2 = ni(), n = ni(); int[] up = new int[n], rp = new int[n]; String wf = n(); for (int i = 0; i < n; i++) { switch (wf.charAt(i)) { case '...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
675d7cf0c15c6e04d453c520ecc5eab8
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.util.*; import java.io.*; public class Main { static int n; static long x1, y1, x2, y2; static char[] arr; static long[] dxs, dys; public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line =...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
d7750b69d5a66046113ec308b5ab90b5
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; /* BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); Integer.parseInt(st.nextToken()); Long.parseLong(st.nextToken()); Scanner sc = new Scanner(System.in); */ public class issam3...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
6175632e2d6ddfa56e3197fbd2a2f87a
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.util.*; public class magicship { static long dx,dy; static int x1,y1,x2,y2; public static void main(String[] args) { Scanner scan=new Scanner(System.in); x1=scan.nextInt(); y1=scan.nextInt(); x2=scan.nextInt(); y2=scan.nextInt(); int n=scan.nextInt(); char[] s=scan.next().toCharArray(); ...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
1ae0e3b11069ada4cb69012a89137299
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.*; public class Main { static int x1; static int y1; st...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
35e982c14687bccf13548c5393a78f9f
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C { static long oo = Long.MAX_VALUE/3; static int n; static long[] cx, cy; static int[] dx = new int[256]; static int[] dy = new int[256]; public static void main(String[] args) { dx['L'] = -1; dx...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
9cd85559ea903a6940e495cd9578b84c
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out); int t = 1; Solver s = new Solver(); for (int i = 1; i <= t; i++) { ...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
e60e374c7cfaccaa9f2ae636718d75ad
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.*; import java.util.InputMismatchException; public class C { public static void main(String args[]) throws Exception { int x1 = scn.nextInt(); int y1 = scn.nextInt(); int x2 = scn.nextInt(); int y2 = scn.nextInt(); int n = scn.nextInt(); String s = sc...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
f21b831cfebbbeb8575563f9a0836ddc
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Jenish */ public class Ma...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
204036f064abed4a68f22e7b5ce1d930
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.*; import java.util.*; import java.util.concurrent.ThreadLocalRandom; public class Main { public static void main(String[] args) throws FileNotFoundException { ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in), new PrintWriter(System.out)); // String fileName = "C-large-p...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
cef03aa2a80ec7b6f4ea99a7f6b62426
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.StringTokenizer; import static java.lang.Math.*; import static java.util.Arrays.fill; p...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
e99a9b7fee992703ab5d5c3a13d52450
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.StringTokenizer; import static java.lang.Math.*; import static java.util.Arrays.fill; p...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
df3bad153fb2656b32e0d9bc31318149
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.StringTokenizer; import static java.lang.Math.*; import static java.util.Arrays.fill; p...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
e6bfe966d1fda4917b3b78d6bf483089
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
//created by Whiplash99 import java.io.*; import java.util.*; public class C { private static Pair[] prefix; static class Pair { long x, y; Pair(){} } private static long _lb(long X1, long Y1, long X2, long Y2, int N) { long l=1, r=(long)(2e14), mid, ans=-1; while...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
fbc0dca5d027fb4e7259c84c9c779a01
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.util.*; public class magicship { static long dx,dy; static int x1,y1,x2,y2; public static void main(String[] args) { Scanner scan=new Scanner(System.in); x1=scan.nextInt(); y1=scan.nextInt(); x2=scan.nextInt(); y2=scan.nextInt(); int n=scan.nextInt(); char[] s=scan.next().toCharArray(); ...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
e18036cd85e5783882cc22c6180051ba
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { static long fac[], ifac[], DR[] = new long[101]; static int MOD = (int) (1e9 + 7); static boolean[] isPrime; static int minPrime[]; static long dp[][]; static int n; static int d, x, y; public static void mai...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
acab7752924335ecd3aa000bb303df46
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.*; import java.util.*; public class magicship { public static void main(String[] args) throws IOException{ BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(f.readLine()); int x = Integer.parseInt(st.nextToken()); int y = Integer.p...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
b45d00e044ae0f3b9e0cdc90b121c930
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Throwable { Scanner sc = new...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
05d18b90ef517883f820c4d66ac2bf98
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
/*Author: Satyajeet Singh, Delhi Technological University*/ import java.io.*; import java.util.*; import java.text.*; import java.lang.*; public class Main { /*********************************************Constants******************************************/ static PrintWriter out=new PrintWriter(new OutputStreamWr...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
e61917b112d9c7ca2257009cff586d08
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
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.util.InputMismatchException; import java.io.IOException; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.Input...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
602651f2c20365aad2bc88661f5d0d73
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
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.util.InputMismatchException; import java.io.IOException; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.Input...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
83e9c7065039be9cee7528235ad30161
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
//package educational.round60; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class C { InputStream is; PrintWriter out; String INPUT = ""; void solve() { long x1 ...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
aebf2b92a1f96c242ea2b76d6beb6b9b
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.*; /* spar5h */ public class cf3 implements Runnable { public void run() { InputReader s = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); int dx = s.nextInt(), dy = s.nextInt(); dx = s.nextInt() - dx; dy ...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
f61b0f822ccc543c9ea6c5f061fb47a3
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigInteger; import jav...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
d0ba33cbba7e256050415ff36821e678
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.*; import java.util.*; public class Task { public static void main(String[] args) throws IOException { new Task().go(); } PrintWriter out; Reader in; BufferedReader br; Task() throws IOException { try { //br = new BufferedReader( new FileReader("...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
46082fcf03587a7906df34d2d92c7e84
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.util.*; public class CodeForces1117C{ static long dx,dy; static int x1,y1,x2,y2; public static void main(String[] args) { Scanner input = new Scanner(System.in); x1 = input.nextInt(); y1 = input.nextInt(); x2 = input.nextInt(); y2 = input.nextInt(); int n = input.nextInt(); char[] s = inpu...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
4a9a950ad27766ed7713e63c620580b8
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
c8ff2bb03106972c64e51ec39b99a8f9
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; import java.awt.Point; public class Main { //static final long MOD = 998244353L; //static final long INF = -1000000000000000007L; static final long MOD = 1000000007L; //static final int INF = 1000000007; public static void main(String[] args) { FastS...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
2f4c81c0a98e6c0922c99a191e1b4744
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
//package sept; import java.io.*; import java.util.*; public class TimePass implements Runnable { InputStream is; PrintWriter out; String INPUT = ""; //boolean debug=false; boolean debug=true; static long mod=998244353; static long mod2=1000000007; void solve() throws IOExceptio...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
b299722fc5842b559c00578f87c1f6f3
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
//package sept; import java.io.*; import java.util.*; public class TimePass implements Runnable { InputStream is; PrintWriter out; String INPUT = ""; //boolean debug=false; boolean debug=true; static long mod=998244353; static long mod2=1000000007; void solve() throws IOExceptio...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
b06e05750f002de1f192bb2ad274dde6
train_000.jsonl
1550504400
You a captain of a ship. Initially you are standing in a point $$$(x_1, y_1)$$$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $$$(x_2, y_2)$$$. You know the weather forecast — the string $$$s$$$ of length $$$n$$$, consisting only of letters U, D, L and R. Th...
256 megabytes
//package sept; import java.io.*; import java.util.*; public class TimePass implements Runnable { InputStream is; PrintWriter out; String INPUT = ""; //boolean debug=false; boolean debug=true; static long mod=998244353; static long mod2=1000000007; void solve() throws IOExceptio...
Java
["0 0\n4 6\n3\nUUU", "0 3\n0 0\n3\nUDD", "0 0\n0 1\n1\nL"]
2 seconds
["5", "3", "-1"]
NoteIn the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: $$$(0, 0)$$$ $$$\rightarrow$$$ $$$(1, 1)$$$ $$$\rightarrow$$$ $$$(2, 2)$$$ $$$\rightarrow$$$ $$$(3, 3)$$$ $$$\rightarrow$$$ $$$(4, 4)$$$ $$$\rightarrow$$$ $$$(4, 6)$$$.In the second e...
Java 8
standard input
[ "binary search" ]
3967727db1225c4b6072d9f18e0dce00
The first line contains two integers $$$x_1, y_1$$$ ($$$0 \le x_1, y_1 \le 10^9$$$) — the initial coordinates of the ship. The second line contains two integers $$$x_2, y_2$$$ ($$$0 \le x_2, y_2 \le 10^9$$$) — the coordinates of the destination point. It is guaranteed that the initial coordinates and destination point ...
1,900
The only line should contain the minimal number of days required for the ship to reach the point $$$(x_2, y_2)$$$. If it's impossible then print "-1".
standard output
PASSED
2f673ecd32c98f7ab63d4e9427874497
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
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) { MyScanner sc = new MyScanner(); int n = sc.nextInt(); int len = 1; int prev = sc.nextInt(); int max =...
Java
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
5758f37f288bbb6861a452c46d04fe13
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; import java.util.Stack; public class C { static long totalDay = 0; static int k; public static void main(String[] args) { S...
Java
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
37148f8a4276b3d28e37097b189cf012
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
256 megabytes
import java.io.*; import java.util.*; public class C implements Runnable{ public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();} public void run() { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); System.err.println("Go!"); int n = fs...
Java
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
90a8b795f79321c5079e20b86d840411
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
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
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
d7562338fbe0a9523809ccb5f502b56b
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
256 megabytes
import java.util.*; import java.util.stream.*; import java.io.*; import java.math.*; public class Main { static boolean FROM_FILE = false; static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { if (FROM_FILE) { t...
Java
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
e0de4f445aa80ea75edab8db77221dba
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * @author khokharnikunj8 */ public class Main { public static void main(String[] args) { ...
Java
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
aa4e1ec694edbe6735b3cb384146b706
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
256 megabytes
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.Scanner; import java.util.StringTokenizer; pub...
Java
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
012f81fd3d3ce3161dd51e292fde6a91
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int y=0; int last = 0; int ans = 1; int max = Integer.MIN_VALUE; int[] data = new int[200000]; for(int i=0;i<n;i++){ int t = scanner.nextInt(...
Java
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
5b53f3bfe379acceff67444f6d27a483
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
256 megabytes
import java.io.*; import java.util.*; public class CFC { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; private static final long MOD = 1000L * 1000L * 1000L + 7; private static final int[] dx = {0, -1, 0, 1}; private static final int[] dy = {1, 0, -1, 0}; privat...
Java
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
6645bcf96cf5e19a682e0ee49aa13495
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
256 megabytes
import java.util.*; import java.io.*; import static java.lang.Math.abs; public class Main { static class Reader { BufferedReader in; Reader() throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); } Reader(String name) throws IOException { ...
Java
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
07a7db970ac32426222806990bf6ed3b
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
256 megabytes
import java.io.*; import java.lang.*; public class CF954C{ public static void main(String args[]) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s[] = br.readLine().split(" "); int n = Integer.parseInt(s[0]); s = br.readLine().spl...
Java
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
b0bb69231fe51f5526c2ce978bde13dd
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class ProblemC { String fileName = "prizes"; public void solve() throws IOException { int n = nextI...
Java
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
f17516a87c94df9d1d0f25237881689d
train_000.jsonl
1521698700
There is a matrix A of size x × y filled with integers. For every , Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cel...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.OutputStream; import java.io.Writer; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author palayutm */ pub...
Java
["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10"]
1 second
["YES\n3 3", "NO", "YES\n4 9"]
NoteThe matrix and the path on it in the first test looks like this: Also there exist multiple correct answers for both the first and the third examples.
Java 8
standard input
[ "implementation" ]
3b725f11009768904514d87e2c7714ee
The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.
1,700
If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be p...
standard output
PASSED
6c41222d10f8736d6e22968d882d193b
train_000.jsonl
1557671700
Let $$$c$$$ be some positive integer. Let's call an array $$$a_1, a_2, \ldots, a_n$$$ of positive integers $$$c$$$-array, if for all $$$i$$$ condition $$$1 \leq a_i \leq c$$$ is satisfied. Let's call $$$c$$$-array $$$b_1, b_2, \ldots, b_k$$$ a subarray of $$$c$$$-array $$$a_1, a_2, \ldots, a_n$$$, if there exists such ...
256 megabytes
// https://codeforces.com/contest/1158/submission/54045740 (ecnerwala) // upsolve with rainboy import java.io.*; import java.util.*; public class CF1158F { static final int MD = 998244353; static long power(int a, int k) { if (k == 0) return 1; long p = power(a, k / 2); p = p * p % MD; if (k % 2 == 1) ...
Java
["4 1\n1 1 1 1", "3 3\n1 2 3", "5 2\n1 2 1 2 1"]
6 seconds
["0 4 6 4 1", "6 1 0 0", "10 17 4 0 0 0"]
NoteIn the first example, it's easy to see that the density of array will always be equal to its length. There exists $$$4$$$ sequences with one index, $$$6$$$ with two indices, $$$4$$$ with three and $$$1$$$ with four.In the second example, the only sequence of indices, such that the array will have non-zero density i...
Java 8
standard input
[ "dp", "math" ]
95c277d67c04fc644989c3112c2b5ae7
The first line contains two integers $$$n$$$ and $$$c$$$, separated by spaces ($$$1 \leq n, c \leq 3\,000$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$, separated by spaces ($$$1 \leq a_i \leq c$$$).
3,500
Print $$$n + 1$$$ numbers $$$s_0, s_1, \ldots, s_n$$$. $$$s_p$$$ should be equal to the number of sequences of indices $$$1 \leq i_1 &lt; i_2 &lt; \ldots &lt; i_k \leq n$$$ for all $$$1 \leq k \leq n$$$ by modulo $$$998\,244\,353$$$, such that the density of array $$$a_{i_1}, a_{i_2}, \ldots, a_{i_k}$$$ is equal to $$$...
standard output