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
23e4ac80517065477bae0e0c68188589
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.InputStream;...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
1653057143d385d8c856cbceb160427d
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
4148b8c65fc56281f40fc295cf0b0486
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; public class P1{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); int s=sc.nextInt(); int k=sc.nextInt(); ArrayList<Integer> a=new ArrayList<Integer>(); for (int i=0;i<k;++i) ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 8
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
70b0c602fb5b191adbd31c1098f99fe7
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.*; public class Solution{ static Scanner sc = new Scanner(System.in); public static void main(String args[]){ int n = sc.nextInt(); int[]arr = new int[n]; for(int i=0;i<n;i++) arr[i] = sc.nextInt(); int ptr1=0,ptr2=0; int cur = 1,max = 1; for(int i=0;i<n;i++){ ptr1 = ptr2 = i; b...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
7b1a0cb4f9d8a655062e9d4ea2a0f18b
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static int[] arr, values; static int max; public static void main(String[] args) throws IOException { BufferedReader br = ne...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
1a66236b2067ba3b501c85395266137c
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Intege...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
f7cbdddc85b1e857828114f6da384145
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.*; public class judge { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int length = scanner.nextInt(); int[] parts = new int[length]; int sum = 0; int max = 0; for (int index = 0; index < length; index++) { ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
36afa5bdb52d770680841115dc69b03e
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.*; public class interview { public static void main(String[] args) { gardenRain(); } public static void gardenRain() { Scanner sc= new Scanner(System.in); int n= sc.nextInt(); // System.out.println(n); int [] levels = new int[n]; int i_reached = 1; int left = 0; int right = 0...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
e7fd641bd7e831bbc4a3c4f2439891a1
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class ArtificialRain { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n; do{ n=sc.nextInt(); }while((n<1)||(n>1000)); int tab[] = new int[n]; for(int i=0;i<tab.length;i++){ ta...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
c6d16607c4b10fefadbde52af6e5a21a
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class Smart { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n =sc.nextInt(); int a[]=new int[n]; int x=0; int max=1; for (int i = 0; i < n; i++) { a[i]=sc.nextInt(); } for (int i = 1; ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
96aeef6e7f730ec77aabdae085c031bd
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class NewClass { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int max = 1; int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } if (a....
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
2a2716db5956f662b84d1003936c6cf9
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; import java.util.List; import java.util.ArrayList; import java.util.LinkedList; import java.util.Map; import java.util.HashMap; import java.util.Set; import java.util.HashSet; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeSet; import java.util.Collections; imp...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
54019eb5f11184c13555f994eba72821
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class Driver { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] a = new int[n]; int max = 0; for (int i = 0; i < a.length; i++) a[i] = scan.nextInt(); for (int i = 0; i < a.length; i++) { int count = 0; ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
55bbeaadb835631f5aa32aa21854b3c8
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class B { public static void main(String[] args) { FastReader in = new FastReader(System.in); PrintWriter pw = new PrintWriter(System.out); ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
06d0006d2577e13ad5bbd7c7437f045f
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
//PetyaAndCountrySide import java.io.*; import java.util.*; public class PetyaAndCountrySide{ static int t,n; static StringBuilder ans=new StringBuilder(); static int[] arr; public static long solve(){ long max_value=0; if(n==1){return 1;} for(int i=0;i<n;i++){ long water=0; int ptr1=i,ptr2=i; while(...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
d19fc954e1810fb8beaba4d33a99f439
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
/* Aman Agarwal algo.java */ import java.util.*; import java.io.*; public class B66 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
3dafae3684d9e0ef5d27f6541ae345a9
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] sec = new int[n]; int[] drops = new int[n]; for(int i = 0; i < n; i++){ sec[i] = in.nextInt(); } for(int i = 0; i < n; i++)...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
89de1bc723d80dd1c3bc89d5e1383d74
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.io.*; import java.util.*; import java.util.regex.Matcher; import java.util.regex.*; public class Solution { static class Task{ public void solve(InputReader in, PrintWriter out) { int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
fbaa504edadadfcb8d4d310ebb2ebebe
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class Main { private void solve() throws Exception{ int n = ri(); int[] a = ria(n); int max = Integer.MIN_VALUE; for(int i = 0; i < n; i++){ int area = 1; for (int j = i-1; j >= 0; j...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
62b573260388d430edae3ac5f6831119
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.io.*; import java.util.*; public class sandbox { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); int n = Integer.parseInt(...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
7dfa8ed569f0da0a37455646367afed6
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; for(int i=0;i<n;i++) { arr[i] = sc.nextInt(); } int max = Integer.MIN_VALUE; for(int i=0;i<n;i++) { int c = arr[i]; int ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
7003c3711ac8dfc4f7fb82a6e44daa3e
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; for (int i=0;i<n;i++) { arr[i] = sc.nextInt(); } int max = Integer.MIN_VALUE; ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
8fb462cdcab26a7ffc93d5d9ed88a580
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class PetyaAndCountryside { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] arr = new int[n]; int j = 0; while (n-- > 0) { arr[j++] = s.ne...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
156691e4f184684cdc63bf79e1871b00
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.io.*; import java.util.InputMismatchException; public class CF66 { static String filePath = "/home/bishoy/IdeaProjects/Arabic competetive programming/src/b/test"; public static void main(String args[]) { InputReader inputReader = Helper.readInput(Helper.Input.STD, filePath); Outpu...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
ac0168e2a8c5389c6b7a9cc3b85b0c76
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.*; public class HelloWorld{ public static void main(String []args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[n]; int m=0,s=0,k=0,ans=0; for(int i=0;i<n;i++) { a[i]=sc.nextInt(); } ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
a51f2017ba4bbbe3b04a322cf650374f
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; public class PetyaAndCountrySide { public static void main(String[] args) throws IOException { BufferedReader br= new BufferedReader(new InputStreamReader(System...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
1325ddd800152203b6659ca0d1ebea50
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class HelloWorld { static Scanner sIn = new Scanner(System.in); public static void main(String[] args) { int n =sIn.nextInt(); int [] arr=new int[n]; int [] acc=new int[n]; for(int i=0;i<n;i++) { arr[i]=sIn.nextInt(); if(i>0&&arr[i]>=arr[i-1]) acc[i]=acc[i-1...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
f32e6a2d54dae944ca5d80a5655fe910
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class ProblemSolving { public static void main(String[] args) { Scanner s = new Scanner(System.in); int x = s.nextInt(); int arr[] = new int[x]; for (int i = 0; i < x; i++) { int z = s.nextInt(); arr[i] = z; } ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
5594c21036a32e2b1b8b9bc3cf7f7184
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int sectionsLength = scanner.nextInt(); String sectionsHeight = scanner.nextLine(); int[] arr = new int[sectionsLength]; int max=0; for (...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
703401e0193168d02ac22e406322b70d
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.*; public class MAIN { static Scanner in = new Scanner(System.in); static int a[]=new int[1001]; public static void main(String[] arge) { int n=in.nextInt(); for(int i=0;i<n;i++) { a[i]=in.nextInt(); } int ans=0; for(int i=0;i<n;i++) { int l,r; r=l=i; int c=1; boo...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
d30af6c94fff3cbb178bf893772d439c
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.lang.reflect.Array; import java.util.Arrays; import java.util.Scanner; public class Codeforces { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int size = sc.nextInt(); int land[] = new int[size]; int solution[] = new int[size]; for(int i=0;i<size;i++) { la...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
da84fc7d3b65c32d82dc4370da5d04b1
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Codeforces { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int size = sc.nextInt(); int land[] = new int[size]; int solution[] = new int[size]; for(int i=0;i<size;i++) { land[i] = sc.nextInt(); } ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
b4a07f9fb511a28740acb7a51207b900
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.*; public class Main { public static int checkAfter( int index , int arr [] ){ int counter = 0; int pointer = index; for (int i = index; i < arr.length-1 ;i++){ if ( arr[pointer] >= arr[i+1]){ ++pointer; ++counter; } ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
c1897f76b70abdaed9e22402342690e2
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
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
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
8f0a1cb4eb15bae4bf5e8764801b65fc
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
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 Main { static InputStream is; static PrintWriter out; static String INPUT = ""; static int lenbuf = 0...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
8567b1e70380f8f054a13197ee087889
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class PetyaAndCountryside { public static void main(String[] args) { ArrayList<Integer> array=new ArrayList(); Scanner s=new Scanner(System.in); int n=s.nextInt(); int []arr=new int[n]; int c=1; int f=0; ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
33167ac9e46059c957782c35c5717284
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.beans.Visibility; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.PriorityQueue; ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
ab4ef2f63d2390cff46e018f65e93c31
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
//package javaapplication1; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.lang.reflect.Array; import static java.lang.reflect.Array.set; imp...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
502c3e3a4e794bf1479d00aec20b6baf
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.System.in; ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
90dfacd195ff521bdce7dc368beb497a
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.*; import java.io.*; public class PatyaAndCountrySide { static int boom[]; static int n; public static void main(String[]args) throws NumberFormatException, IOException{ BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); n = Integer.parseInt(bf.readLine()); boom = new in...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
5714fbf0e8e10bddff8b981ac3905563
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
public class Main { public static void main(String[] args) { java.util.Scanner sc=new java.util.Scanner(System.in); int n1=sc.nextInt(); int arr[]=new int [n1]; boolean arr2 []=new boolean [n1]; for(int j=0;j<n1;j++){ arr[j]=sc.nextInt(); } int min=min(arr); int max=max(arr); while(min!=ma...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
b0fdfee8d78d151c4c8990227c5f86b7
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class NewClass { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), max = 1; int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } if (a.length == 1)...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
3aa2b7547ae4bf8e01d60505af528314
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.*; public class Rain { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int arr[] = new int[n]; for (int i = 0; i < n; i++) arr[i] = sc.nextInt(); int max = 0; for (int i = 0; i < n; i++)...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
b1264a4c1dce26d17e84694c90b9dce5
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class c2 { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); int []arr=new int[n]; for(int i=0;i<n;i++){ arr[i]=scn.nextInt(); } int []left=new int[n]; int val=arr[0]; ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
ee46c264a6dacefb019598f0ba1a047d
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; public class Mainn { public static void main(String[] args) { Scanner input= new Scanner(System.in); int n= input.nextInt(); int a []=new int[n]; int b[]=new int[n]; int r,m,count; for(int i=0;i<n;i++){ a[i]=input.nextInt(); ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
8cb5677886ea908bef3725b78deca3d3
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.Scanner; /** * * @author Fares Abu Ali */ public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int max = 0; int n = sc.nextInt(); int[] str = new int[n]; for(int i=0; i<n; i++) str[i]=s...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
30070ce88d62fac214e6e7a90bcb506b
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.io.*; import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementFactory; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; import static java.lang.Math.sqrt; public class PetyaAndCountry { public void run() throws Exception { i...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
0fc7eaa8afdd17535c628b05c1979747
train_001.jsonl
1299513600
Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections possesses its own fixed h...
256 megabytes
import java.util.*; import java.io.*; public class Main66B { static PrintWriter out=new PrintWriter(System.out); public static void main(String[] args) throws IOException { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=sc.nextIntArray(n); int max=0; for(int i=0;i<n;i++) ...
Java
["1\n2", "5\n1 2 1 2 1", "8\n1 2 1 1 1 3 3 4"]
2 seconds
["1", "3", "6"]
null
Java 8
standard input
[ "implementation", "brute force" ]
5d11fa8528f1dc873d50b3417bef8c79
The first line contains a positive integer n (1 ≤ n ≤ 1000). The second line contains n positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
1,100
Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
standard output
PASSED
6765224e42cc02e91413a5e8ade15b96
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Solution { public static void main(String[] args) { /* * */ Scanner scan = new Scanner(System.in); int n=scan.nextInt(); int m=scan.nextInt(); int[][] arr = new int[n][m]; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { arr[...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
97426386e10b0d2262f9456cd6fbe451
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.Scanner; public class C1231 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int rows = s.nextInt(); int cols = s.nextInt(); int[][] matrix = new int[rows][cols]; int[][] original = new int[rows][cols]; for (int i = 0; ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
d2d28abd3fa9ba7b17c19723d3878c17
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.InputMismatchException; public class C_1231 { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws NumberFo...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
cc91ca3e0dde456a1a1928fe14a159fb
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.*; import java.util.*; public class incmat { public static void main(String args[]) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int m=in.nextInt(); int a[][]=new int[n][m]; int flag=1; for(int i=0;i<n;i++) for(int j=0;j<m;j+...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
5522c585327f59c767fbb16171df0eb7
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.Scanner; // Import the Scanner class public final class Main{ static int[] tempList; public static void main(String[ ] args){ Scanner sc = new Scanner(System.in); int m = sc.nextInt(), n = sc.nextInt(); int[][] tab = new int[m][n]; for(int i=0;i<m;i++) { ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
ba90a417f1ac23a8251fa90900661200
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class Main1 { static PrintWriter out = new PrintWriter(System.ou...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
65f10956d77a91d28a1caad72999236d
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
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
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
6cc00ec259054991efbf84d76a27167c
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.*; public class Codeforces1 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); boolean flag=false; int a[][]=new int[n+1][m+1]; for(int i=1;i<=n;i++){ for(int j=1...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
399e9bb1ed3c6aa875d1f2f9ad4370f8
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; public class Main { public static void main(String[] args) throws IOExce...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
fe9f88bdecc04a634f0c1579b5e97a2d
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
//package com.company; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s[] = br.readLine().split(" "); int n = Integer.parseInt(s[0]); int m = Integer.p...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
60559921bc964951a24959ad4b25acdf
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.Scanner; public class IncreasingMatrix { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] params = sc.nextLine().split(" "); int n = Integer.decode(params[0]); int m = Integer.decode(params[1]); int[][] matrix = new in...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
b190c6c63b147137e3f2ba73a5becc98
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.*; import java.util.*; public class Main { static int inf = (int) (1e9 + 7); public static void main(String[] args) throws IOException { sc = new Scanner(System.in); pw = new PrintWriter(System.out); int n = sc.nextInt(); int m = sc.nextInt(); int a[][]...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
82d465d294289ab5b6643aa0c0617e29
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.*; import java.util.*; // Author : Yash Shah public class D implements Runnable { static int fun(int x,int d) { return x+(int)Math.ceil(d/(float)(x+1)); } public void run() { InputReader sc = new InputReader(System.in); PrintWriter out = new PrintWrit...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
1649467f364b515c73144fc634c83451
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Cf182 implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCha...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
f48fc8eca5dcf43668a010ad5779dae2
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.*; import java.lang.*; import java.math.*; import java.text.*; import java.io.*; public final class Solution { static PrintWriter out = new PrintWriter(System.out); static void flush() { out.flush(); } static class FastReader { BufferedReader br; StringTokenize...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
382d4d3773dc2d3ee87421e430a18ee0
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
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.LinkedList; import java.util.List; import java.util.Map; import java.util.PriorityQueue; import java.util.Queue; import java.util.Scanner; ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
12b5f6662de51b439e7993d948fd9fd2
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.Scanner; public class Solution { public static void main(String args[]) { Scanner s=new Scanner(System.in); int rows=s.nextInt(); int cols=s.nextInt(); int[][] matrix=new int[rows][cols]; for(int i=0;i<rows;i++) { for(int j=0;j<cols;j++) ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
dbb48bbbcab4e61a2cdbfdea0017f91e
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
//189301019.akshay import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.Random; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class C { public stat...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
ab9a744e8ffaba02ec0db9f9dbe1ffd8
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Matrix { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s[] = br.readLine().split(" "); in...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
7286f3ca94e645e22965760e83e891be
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
//Increasing Matrix import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.StringTokenizer; public class IncreasingMatrix { public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); S...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
2032eb528b5b292bca7bb45f64644a5f
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.*; public class _1231c_IncreasingMatrix { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int n=scn.nextInt(); int m=scn.nextInt(); int[][]array=new int[n][m]; long sum=0; boolean b=true; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { array[i][j]=sc...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
4de47d23e8574706eff1a84e0a7b3521
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.*; import java.util.*; public class ProgEc { public static void main(String[] args) throws Exception { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Solver so...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
a9871cdc874c410130338de2dc29ec58
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; //Mann Shah [ DAIICT ]. //fast io public class Main { public static int mod = (int) (1e9 + 7); static InputReader in; static PrintWriter out; public static long gcd(long a, long b) { if (a == 0) return b; return gcd(b % a, a); } public ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
6acfd4624f6c3f52af000e9716ffc18f
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.Scanner; import static java.lang.Math.max; public class Myclass { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int m = scan.nextInt(); int a[][] = new int[n][m]; for (int i = 0; i <n; i++) { ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
7723d25522b96dc9ff2d7e574b35afe2
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); int m = scanner.nextInt(); int n = scanner.nextInt(); int[][] a = new int[m][n]; for(int i = 0; i ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
90c1f75f514ab48455c7d4a04d4501ef
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.Scanner; import static java.lang.Math.max; public class Myclass { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int m = scan.nextInt(); int a[][] = new int[n][...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
f8b0b3b2ebb51fd6ee536f4f82173ffb
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class increasingmatrix { public static void main(String[] args) { FS s=new FS(); int n=s.nextInt(); int m=s.nextInt(); int[][] matrix=new int[n][m]; for(int i=0;i<n;i++)for(int ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
883da362156cebaa168894e82769af50
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
//package codeforces; import java.io.*; import java.util.InputMismatchException; /** * @author tainic on May 2, 2020 */ public class P1231C { private static boolean LOCAL; static { try { LOCAL = "aurel".equalsIgnoreCase(System.getenv().get("USER")); } catch (Exception e){} } private static...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
5955296d2eaedf1762af65eacb28d83c
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int sum = 0; int ans = 0; int[][] matrix = new int[n][m]; for (int i = 0; i < n; i++){ for (int j =...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
0a832503bd91699d4ffed3d1db70b02c
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
/*** * ██████╗=====███████╗====███████╗====██████╗= * ██╔══██╗====██╔════╝====██╔════╝====██╔══██╗ * ██║==██║====█████╗======█████╗======██████╔╝ * ██║==██║====██╔══╝======██╔══╝======██╔═══╝= * ██████╔╝====███████╗====███████╗====██║===== * ╚═════╝=====╚══════╝====╚══════╝====╚═╝===== * ===...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
148c91f34090b887a1b888e7783a7614
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
/*** * ██████╗=====███████╗====███████╗====██████╗= * ██╔══██╗====██╔════╝====██╔════╝====██╔══██╗ * ██║==██║====█████╗======█████╗======██████╔╝ * ██║==██║====██╔══╝======██╔══╝======██╔═══╝= * ██████╔╝====███████╗====███████╗====██║===== * ╚═════╝=====╚══════╝====╚══════╝====╚═╝===== * ===...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
9fa46d004b358222a1ee51861aece5af
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.*; public class Sol1{ public static void main(String[] args) throws IOException { Reader sc=new Reader(); int n=sc.nextInt(); int m=sc.nextInt(); int[][]a=new int[n][m]; ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
9f2cdbf3f319a0682f49aee4a4f8580f
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.Scanner; public class C1231 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int R = in.nextInt(); int C = in.nextInt(); int[][] A = new int[R][C]; for (int r=0; r<R; r++) { for (int c=0; c<C; c++) { ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
07ffffc094562ed793292db53df07f3b
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
//package codeforces; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Gabbar { static boolean isPrime(long n, long i) { // Base cases if (n <= 2) { return (n == 2) ? true : false; } if (n % i == 0) { return...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
824815af43ecff2e7b1b400bb8b7e5bc
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { BufferedReader bf = new BufferedReader(new ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
c094e37ad5b34559f5a8badb1b879618
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { BufferedReader bf = new BufferedReader(new ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
85f6bac70b3cc279443fb18df3579e70
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.i...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
fcad455aea17fb3a3eb1a7ee9c3abb0a
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.Scanner; public class IncreasingMatrix { public static void main(String[] args) { Scanner sc =new Scanner(System.in); int n=sc.nextInt(),m=sc.nextInt(); int arr[][]=new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { arr[i][j]=sc.nextInt(); } } ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
6a0f5b101466d677f4333e8ef85a2a6f
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { //static final long MOD = 998244353; static final long MOD = 1000000007; static boolean[] visited; public static void main(String[] args) throws IOException { FastScanner sc=new FastScanner(); int N = sc.nextInt(); ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
b3a10eaeb3ade541499d807810f07567
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** If I'm the sun, you're the moon Because when I go up, you go down ******************************* I'm working for the day I will surpass you https://www.a2oj.com/Ladder16.html */ impor...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
a370e3e270281f53d0b69a7f5ad97884
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** If I'm the sun, you're the moon Because when I go up, you go down ******************************* I'm working for the day I will surpass you https://www.a2oj.com/Ladder16.html */ impor...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
1b7bd29523f38580d1d28956fe6e58ae
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package practice; import java.util.Scanner; /** * * @author 97156 */ public class Practice { /** * @param args the com...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
58e3a40621571227e528b4631c83acf9
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class MaxSum{ public static void main(String[] args) throws IOException { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); // System.out.println(n); in...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
b47e9b3202d1e56be61bfd1a365e5bfd
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
//package codeForces; import java.util.Arrays; import java.io.FileNotFoundException; import java.util.*; import java.math.BigInteger; import java.util.Scanner; import java.math.*; public class Test { static int[][] array; static int getLeft(int x, int y) { for (int j = y - 1; j >= 0; j--) { if (array[x][j] != 0)...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
de9c3bb435f0de1231f6f53c6707665e
train_001.jsonl
1569143100
In this problem, a $$$n \times m$$$ rectangular matrix $$$a$$$ is called increasing if, for each row of $$$i$$$, when go from left to right, the values strictly increase (that is, $$$a_{i,1}&lt;a_{i,2}&lt;\dots&lt;a_{i,m}$$$) and for each column $$$j$$$, when go from top to bottom, the values strictly increase (that is...
256 megabytes
import java.util.Scanner; public class IncreasingMatrix { public static void main(String[] args) { Scanner sc =new Scanner(System.in); int n=sc.nextInt(),m=sc.nextInt(); int arr[][]=new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { arr[i][j]=sc.nextInt(); } } ...
Java
["4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12", "3 3\n1 2 3\n2 0 4\n4 5 6", "3 3\n1 2 3\n3 0 4\n4 5 6", "3 3\n1 2 3\n2 3 4\n3 4 2"]
2 seconds
["144", "30", "-1", "-1"]
NoteIn the first example, the resulting matrix is as follows: 1 3 5 6 73 6 7 8 95 7 8 9 108 9 10 11 12In the second example, the value $$$3$$$ must be put in the middle cell.In the third example, the desired resultant matrix does not exist.
Java 8
standard input
[ "greedy" ]
ebc5c1fe4b4a253647b82a608e8a084f
The first line contains integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 500$$$) — the number of rows and columns in the given matrix $$$a$$$. The following lines contain $$$m$$$ each of non-negative integers — the values in the corresponding row of the given matrix: $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$0 \le a_{i...
1,100
If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.
standard output
PASSED
5898a63421b373b34d4e3ad5a12bfb46
train_001.jsonl
1346081400
The country Treeland consists of n cities, some pairs of them are connected with unidirectional roads. Overall there are n - 1 roads in the country. We know that if we don't take the direction of the roads into consideration, we can get from any city to any other one.The council of the elders has recently decided to ch...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.TreeMap; import java.util.StringTokenizer; public class D { // 135 div2 static int[] red, green; static ArrayList<Integer>[] adList; static int totalRed = 0; pu...
Java
["3\n2 1\n2 3", "4\n1 4\n2 4\n3 4"]
3 seconds
["0\n2", "2\n1 2 3"]
null
Java 6
standard input
[ "dp", "dfs and similar", "trees", "graphs" ]
fb5c6182b9cad133d8b256f8e72e7e3b
The first input line contains integer n (2 ≤ n ≤ 2·105) — the number of cities in Treeland. Next n - 1 lines contain the descriptions of the roads, one road per line. A road is described by a pair of integers si, ti (1 ≤ si, ti ≤ n; si ≠ ti) — the numbers of cities, connected by that road. The i-th road is oriented fro...
1,700
In the first line print the minimum number of roads to be inversed if the capital is chosen optimally. In the second line print all possible ways to choose the capital — a sequence of indexes of cities in the increasing order.
standard output
PASSED
209dc3a96b16c78f02cb4710c933c6ac
train_001.jsonl
1600526100
An agent called Cypher is decrypting a message, that contains a composite number $$$n$$$. All divisors of $$$n$$$, which are greater than $$$1$$$, are placed in a circle. Cypher can choose the initial order of numbers in the circle.In one move Cypher can choose two adjacent numbers in a circle and insert their least co...
256 megabytes
import java.util.*; import java.io.*; public class Main { static class Scan { private byte[] buf=new byte[1024]; private int index; private InputStream in; private int total; public Scan() { in=System.in; } public int scan()throws IOExcepti...
Java
["3\n6\n4\n30"]
1 second
["2 3 6 \n1\n2 4 \n0\n2 30 6 3 15 5 10 \n0"]
NoteIn the first test case $$$6$$$ has three divisors, which are greater than $$$1$$$: $$$2, 3, 6$$$. Regardless of the initial order, numbers $$$2$$$ and $$$3$$$ are adjacent, so it's needed to place their least common multiple between them. After that the circle becomes $$$2, 6, 3, 6$$$, and every two adjacent number...
Java 11
standard input
[ "constructive algorithms", "implementation", "number theory", "math" ]
406f8f662d2013d87b36dacca663bef5
The first line contains an integer $$$t$$$ $$$(1 \le t \le 100)$$$ — the number of test cases. Next $$$t$$$ lines describe each test case. In a single line of each test case description, there is a single composite number $$$n$$$ $$$(4 \le n \le 10^9)$$$ — the number from the message. It's guaranteed that the total num...
2,100
For each test case in the first line output the initial order of divisors, which are greater than $$$1$$$, in the circle. In the second line output, the minimal number of moves needed to decrypt the message. If there are different possible orders with a correct answer, print any of them.
standard output
PASSED
f8a6dbd451f14af02f6a50fdc953b16e
train_001.jsonl
1600526100
An agent called Cypher is decrypting a message, that contains a composite number $$$n$$$. All divisors of $$$n$$$, which are greater than $$$1$$$, are placed in a circle. Cypher can choose the initial order of numbers in the circle.In one move Cypher can choose two adjacent numbers in a circle and insert their least co...
256 megabytes
import java.io.*; import java.util.*; public class A { public static void main(String[] args) { Scanner inp; try { inp = new Scanner(new File("input.txt")); } catch (FileNotFoundException e){ inp = new Scanner(System.in); } int Tests = inp.nextInt();...
Java
["3\n6\n4\n30"]
1 second
["2 3 6 \n1\n2 4 \n0\n2 30 6 3 15 5 10 \n0"]
NoteIn the first test case $$$6$$$ has three divisors, which are greater than $$$1$$$: $$$2, 3, 6$$$. Regardless of the initial order, numbers $$$2$$$ and $$$3$$$ are adjacent, so it's needed to place their least common multiple between them. After that the circle becomes $$$2, 6, 3, 6$$$, and every two adjacent number...
Java 11
standard input
[ "constructive algorithms", "implementation", "number theory", "math" ]
406f8f662d2013d87b36dacca663bef5
The first line contains an integer $$$t$$$ $$$(1 \le t \le 100)$$$ — the number of test cases. Next $$$t$$$ lines describe each test case. In a single line of each test case description, there is a single composite number $$$n$$$ $$$(4 \le n \le 10^9)$$$ — the number from the message. It's guaranteed that the total num...
2,100
For each test case in the first line output the initial order of divisors, which are greater than $$$1$$$, in the circle. In the second line output, the minimal number of moves needed to decrypt the message. If there are different possible orders with a correct answer, print any of them.
standard output
PASSED
ef565d46a439978821f8f8e52016501d
train_001.jsonl
1600526100
An agent called Cypher is decrypting a message, that contains a composite number $$$n$$$. All divisors of $$$n$$$, which are greater than $$$1$$$, are placed in a circle. Cypher can choose the initial order of numbers in the circle.In one move Cypher can choose two adjacent numbers in a circle and insert their least co...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class SolutionE extends Thread { private static final FastReader scanner = new FastReader(); private static final PrintWriter out = new PrintWriter(System.out); ...
Java
["3\n6\n4\n30"]
1 second
["2 3 6 \n1\n2 4 \n0\n2 30 6 3 15 5 10 \n0"]
NoteIn the first test case $$$6$$$ has three divisors, which are greater than $$$1$$$: $$$2, 3, 6$$$. Regardless of the initial order, numbers $$$2$$$ and $$$3$$$ are adjacent, so it's needed to place their least common multiple between them. After that the circle becomes $$$2, 6, 3, 6$$$, and every two adjacent number...
Java 11
standard input
[ "constructive algorithms", "implementation", "number theory", "math" ]
406f8f662d2013d87b36dacca663bef5
The first line contains an integer $$$t$$$ $$$(1 \le t \le 100)$$$ — the number of test cases. Next $$$t$$$ lines describe each test case. In a single line of each test case description, there is a single composite number $$$n$$$ $$$(4 \le n \le 10^9)$$$ — the number from the message. It's guaranteed that the total num...
2,100
For each test case in the first line output the initial order of divisors, which are greater than $$$1$$$, in the circle. In the second line output, the minimal number of moves needed to decrypt the message. If there are different possible orders with a correct answer, print any of them.
standard output
PASSED
66530df3c4d77f3786f0953f851b8966
train_001.jsonl
1600526100
An agent called Cypher is decrypting a message, that contains a composite number $$$n$$$. All divisors of $$$n$$$, which are greater than $$$1$$$, are placed in a circle. Cypher can choose the initial order of numbers in the circle.In one move Cypher can choose two adjacent numbers in a circle and insert their least co...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Random; import jav...
Java
["3\n6\n4\n30"]
1 second
["2 3 6 \n1\n2 4 \n0\n2 30 6 3 15 5 10 \n0"]
NoteIn the first test case $$$6$$$ has three divisors, which are greater than $$$1$$$: $$$2, 3, 6$$$. Regardless of the initial order, numbers $$$2$$$ and $$$3$$$ are adjacent, so it's needed to place their least common multiple between them. After that the circle becomes $$$2, 6, 3, 6$$$, and every two adjacent number...
Java 11
standard input
[ "constructive algorithms", "implementation", "number theory", "math" ]
406f8f662d2013d87b36dacca663bef5
The first line contains an integer $$$t$$$ $$$(1 \le t \le 100)$$$ — the number of test cases. Next $$$t$$$ lines describe each test case. In a single line of each test case description, there is a single composite number $$$n$$$ $$$(4 \le n \le 10^9)$$$ — the number from the message. It's guaranteed that the total num...
2,100
For each test case in the first line output the initial order of divisors, which are greater than $$$1$$$, in the circle. In the second line output, the minimal number of moves needed to decrypt the message. If there are different possible orders with a correct answer, print any of them.
standard output
PASSED
a8f3a3eb6747e72e14ef21e5e29e2356
train_001.jsonl
1600526100
An agent called Cypher is decrypting a message, that contains a composite number $$$n$$$. All divisors of $$$n$$$, which are greater than $$$1$$$, are placed in a circle. Cypher can choose the initial order of numbers in the circle.In one move Cypher can choose two adjacent numbers in a circle and insert their least co...
256 megabytes
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Map; public class Test1419E { static final BufferedInputStream IN = new BufferedInputStream(System.in); static final Pr...
Java
["3\n6\n4\n30"]
1 second
["2 3 6 \n1\n2 4 \n0\n2 30 6 3 15 5 10 \n0"]
NoteIn the first test case $$$6$$$ has three divisors, which are greater than $$$1$$$: $$$2, 3, 6$$$. Regardless of the initial order, numbers $$$2$$$ and $$$3$$$ are adjacent, so it's needed to place their least common multiple between them. After that the circle becomes $$$2, 6, 3, 6$$$, and every two adjacent number...
Java 11
standard input
[ "constructive algorithms", "implementation", "number theory", "math" ]
406f8f662d2013d87b36dacca663bef5
The first line contains an integer $$$t$$$ $$$(1 \le t \le 100)$$$ — the number of test cases. Next $$$t$$$ lines describe each test case. In a single line of each test case description, there is a single composite number $$$n$$$ $$$(4 \le n \le 10^9)$$$ — the number from the message. It's guaranteed that the total num...
2,100
For each test case in the first line output the initial order of divisors, which are greater than $$$1$$$, in the circle. In the second line output, the minimal number of moves needed to decrypt the message. If there are different possible orders with a correct answer, print any of them.
standard output
PASSED
7cbe136876bcb1542c5c109824174f29
train_001.jsonl
1600526100
An agent called Cypher is decrypting a message, that contains a composite number $$$n$$$. All divisors of $$$n$$$, which are greater than $$$1$$$, are placed in a circle. Cypher can choose the initial order of numbers in the circle.In one move Cypher can choose two adjacent numbers in a circle and insert their least co...
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.Iterator; import java.io.IOException; import java.io.InputStreamReader; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; ...
Java
["3\n6\n4\n30"]
1 second
["2 3 6 \n1\n2 4 \n0\n2 30 6 3 15 5 10 \n0"]
NoteIn the first test case $$$6$$$ has three divisors, which are greater than $$$1$$$: $$$2, 3, 6$$$. Regardless of the initial order, numbers $$$2$$$ and $$$3$$$ are adjacent, so it's needed to place their least common multiple between them. After that the circle becomes $$$2, 6, 3, 6$$$, and every two adjacent number...
Java 11
standard input
[ "constructive algorithms", "implementation", "number theory", "math" ]
406f8f662d2013d87b36dacca663bef5
The first line contains an integer $$$t$$$ $$$(1 \le t \le 100)$$$ — the number of test cases. Next $$$t$$$ lines describe each test case. In a single line of each test case description, there is a single composite number $$$n$$$ $$$(4 \le n \le 10^9)$$$ — the number from the message. It's guaranteed that the total num...
2,100
For each test case in the first line output the initial order of divisors, which are greater than $$$1$$$, in the circle. In the second line output, the minimal number of moves needed to decrypt the message. If there are different possible orders with a correct answer, print any of them.
standard output