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
33605368112227c9ef8fe91e9c1b7379
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
import java.io.*; import java.util.*; public class Template implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void init() throws FileNotFoundException { try { in = new BufferedReader(new FileReader("input.txt")); o...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 8
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≀ n ≀ 105) β€” the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≀ ri ≀ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers β€” the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output
PASSED
3f7911439ea06dbfd2a744e6c9236fce
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
import com.sun.org.apache.bcel.internal.generic.FieldGen; import com.sun.org.apache.xpath.internal.operations.Bool; import java.io.*; import java.math.BigInteger; import java.util.*; public class Template implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 8
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≀ n ≀ 105) β€” the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≀ ri ≀ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers β€” the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output
PASSED
fb252065529371689edca5a253f01a8e
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
import java.io.*; import java.util.*; public class Program { static BufferedReader in; static PrintWriter out; static StringTokenizer tok = new StringTokenizer(""); public static void main(String[] args) throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintW...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 8
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≀ n ≀ 105) β€” the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≀ ri ≀ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers β€” the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output
PASSED
295edc4b441159725c801a217fdcb647
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.OutputStream; import java.util.Set; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; import java.io.FileNotFoundException; import java.io.File; im...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 8
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≀ n ≀ 105) β€” the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≀ ri ≀ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers β€” the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output
PASSED
431248a5ec191b94ce0f948fc08c471a
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; imp...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 8
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≀ n ≀ 105) β€” the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≀ ri ≀ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers β€” the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output
PASSED
6c9b1ac739d9532251f51f15ba8634ef
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
import java.io.*; import java.util.*; public final class blood_cousins_return { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); static Random rnd=new Random(); static TreeMap<String,I...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 8
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≀ n ≀ 105) β€” the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≀ ri ≀ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers β€” the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output
PASSED
ea8c5188e8d51e96bc0e3743177b6435
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
import java.io.*; import java.lang.reflect.*; import java.util.*; public class E { final int MOD = (int)1e9 + 7; final double eps = 1e-12; final int INF = (int)1e9; void expand(int m, List<Integer> [][] CH, boolean [] E) { if (CH[0][m] != null) { for (int p : CH[0][m]) if (!E[p]) expand(p, CH, E...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 6
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≀ n ≀ 105) β€” the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≀ ri ≀ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers β€” the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output
PASSED
3c3f838bc10bfe8b5859c989e13f04cf
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
//package Codeforces; import org.omg.PortableInterceptor.SYSTEM_EXCEPTION; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; /** * Created by rajanW(683281) on 22-May-15. * at 11:41 PM */ public class Main { static ...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
b149f40e55dd57bc4284a6ecb2f5e422
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Code_546D_SoldierAndNumberGame{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamRead...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
862dd2a11eb0cca4287230f9152d1034
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.*; import java.util.*; /* * kishan Thesiya * daiict * kishanthesiya25@gmail.com * * */ public class Main { FastScanner in; PrintWriter out; static ArrayList[] adj; class Item implements Comparable<Item> { int num; int val; public Item(int num, int val) { super(); this....
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
75cdab3c676fbfa0c26c19456fe6c586
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; /** * Created by fly on 9/4/17. */ public class Main { public static int mod = 1000000007; public static int size = 5000000 + 5; public static void main(String[] args) { InputReader in = new InputReader(System.in); ...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
3dba4c4a17411dcc8d382cac1e651242
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.*; import java.util.InputMismatchException; public class Cf304D { private static InputReader in = new InputReader(System.in); private static OutputWriter out = new OutputWriter(System.out); private static void solve() throws Exception { boolean[] isNotPrime = new boolean[5000001]; ...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
27c3816585cccb6db7a61bb37ef77e39
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.util.*; import java.io.*; public class Soldier_and_Number_Game { static int[] dp; static boolean[] isPrime; public static void main(String args[]) throws Exception { BufferedReader f=new BufferedReader(new InputStreamReader(System.in)); int runs=Integer.parseInt(f.readLine()); dp=new int[5000001];...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
57de9d73ced625c65d448cf922e5e3d4
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class SolveContest { private BufferedReader in; private PrintWriter out; public SolveContest() { try { in = new BufferedReader(new FileReader("input.txt")); out = new P...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
f019441a105499208557323c20ac61a6
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.*; import java.util.StringTokenizer; public class Solver { public static final int SIZE = 6000000; private BufferedReader in; private PrintWriter out; Solver() throws IOException { try { in = new BufferedReader(new FileReader("input.txt")); out = new Prin...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
55d275670f61ca007f2218331520bd42
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C546D { private StringTokenizer st; private BufferedReader bf; public C546D(){ try { bf = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokeni...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
f086f54984df53e187ae86dc9fad8f99
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C546D { private StringTokenizer st; private BufferedReader bf; public C546D(){ try { bf = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokeni...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
df13acb8759981bb1a4b3c11b81ca645
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class C546D { private StringTokenizer st; private BufferedReader bf; private static PrintWriter out = new PrintWriter(System.out); public C546D(){ t...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
fd579a8f3dbdbe07f6f1347f29a413fc
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C546D { private StringTokenizer st; private BufferedReader bf; public C546D(){ try { bf = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokeni...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
0de29513495d9624104995d5e5ffad7a
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class C546D { private StringTokenizer st; private BufferedReader bf; private static PrintWriter out = new PrintWriter(System.out); public C546D(){ t...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
6df245da5ca911665727d7027ddfce3b
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C546D { private StringTokenizer st; private BufferedReader bf; public C546D(){ try { bf = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokeni...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
2b050013e87c70874be3a11c2928fd11
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; /** * */ public class TaskD { public static void main(String[] a...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
f5f41dc9cbb23a9475bb7fe0814549fc
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Scanner; import java.util.StringTokenizer; /** * Created by Paul on 5/23/2015. */ public class Main { static InputStream is; static PrintWriter out; static String INPUT = ""; final static int N = 500...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
0cd6a733fe39ce4b28ca27a2729e44c9
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class SoldierAndNumberGame { /** * @param args */ static void sieve() { // create list of primes in [0..upperbound] N = N ...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
fd0f325294adc97fcfa8bc51ab2f1960
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
051ac205a9f30a9b550e0250ec41fb1d
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Arrays; public class NumberGame { static final int limit = (int) 5e6 + 1; static int[] cnt = new int[limit]; static int[] prefix = new int[limit]; public static void ...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
9e303794bfdca008419e6ffda0131ad6
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class NumberGame { static final int limit = (int) 5e6 + 1; static int[] cnt = new int[limit]; ...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
bd4d8a532fad50c0ba73412e09201c27
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static int MOD; public static int[] arr = new int[5000002]; public static void main(String[] args) throws Exception { MyScanner input = new MyScanner(); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); init(); in...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
0b00ed83fe9a86bab44a8b7193630fb4
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.InputMismatchException; public class Queue { public static void main (String[] args) throws Num...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
a869bb67edc3f0ba6c3c1ad2549a05d3
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class D546 { public static void main(String[] args) throws IOException { initReader(); int n = nextInt(); StringBuilder s...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
b3b74e30ea48a860f0f8298eff3908ff
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class D546 { public static void main(String[] args) throws IOException { initReader(); int n = nextInt(); int[] lowestPrimeFacto...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
459977d8c524374fa8fd5e7e50b3ba7c
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class D546 { public static void main(String[] args) throws IOException { initReader(); int n = nextInt(); StringBuilder s...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
5437130275e2814fd00699bba7f45f92
train_001.jsonl
1432312200
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x &gt; 1, such that n is divisible by x and replacing n with n / x. Whe...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class D { public static void main(String args[]) throws IOException { Reader.init(System.in); int t = Reader.nextInt(); int prime[] = new int[50000...
Java
["2\n3 1\n6 3"]
3 seconds
["2\n5"]
null
Java 8
standard input
[ "dp", "constructive algorithms", "number theory", "math" ]
79d26192a25cd51d27e916adeb97f9d0
First line of input consists of single integer t (1 ≀ t ≀ 1 000 000) denoting number of games soldiers play. Then follow t lines, each contains pair of integers a and b (1 ≀ b ≀ a ≀ 5 000 000) defining the value of n for a game.
1,700
For each game output a maximum score that the second soldier can get.
standard output
PASSED
a1f784c9b9fb504fa6c423e1920b5593
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.stream.IntStream; import java.util.Arrays; import java.util.ArrayList; import java.util.OptionalLong; import java.nio.charset.Charset; import java.util.StringTokenizer; import java.io.OutputStreamWriter; import java.ut...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
b77d929270dac108614f965ceec320b1
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import javafx.scene.layout.Priority; import java.io.*; import java.lang.reflect.Array; import java.net.Inet4Address; import java.util.*; import java.lang.*; import java.util.HashMap; import java.util.PriorityQueue; public class templ implements Runnable { static class pair implements Comparable { int f...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
6292aaa04fbb4283a6ebbe8e972933c6
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; //https://codeforces.com/problemset/problem/1108/E2 public class ArrayAndSegments { public static void main(String[] args) throws IOException { BufferedReader br = ne...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
3c3a325bb446426f7168eb5ef6f5b53f
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.io.*; import java.util.*; public class E { static Scanner in=new Scanner(System.in); static PrintWriter out=new PrintWriter(System.out); static int n,T,res=0; static int[] a=new int[100005],SaveL=new int[100005],SaveR=new int[100005]; static int[] tree=new int[400005],lazy=new int[400005]; static ...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
d74dec0345254699950e0c0ac4ce8074
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.util.*; import java.io.*; //267630EY public class Main1108E2 { static PrintWriter out=new PrintWriter(System.out); static class segMent { int[] t; int n; int[] lazy; boolean[] marked; public segMent(int[] a,int n) { this.n=n; lazy=new int[4*n]; marked=new...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
60299c7f691914baa20afde67e3504fa
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.util.*; import java.io.*; //267630EY public class Main1108E2 { static PrintWriter out=new PrintWriter(System.out); static class segMent { int[] t; int n; int[] lazy; boolean[] marked; public segMent(int[] a,int n) { this.n=n; lazy=new int[4*n]; marked=new...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
e0872a5761f02994fd6bce6b07c69b28
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; //Solution Credits: Taranpreet Singh public class Main{ //SOLUTION BEGIN void pre() throws Exception{} void solve(int TC) throws Exception{ int n = ni(), m = ni(); int[] a = new int[n]; for(int i = 0; i< n; i++)a[i] = ni(); ...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
0d305ae5a34e9c929a8269d291b19b37
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
//package round535; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.List; public class E { InputStream is...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
b25caf3c792202bddb711b77c70c33fe
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.io.*; import java.util.*; public class Task { public static void main(String[] args) throws Exception { new Task().go(); } PrintWriter out; Reader in; BufferedReader br; Task() throws IOException { try { //br = new BufferedReader( new FileReader("in...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
a946506b40279c421ad7f9be68cc8286
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class Main { static Tree[] trees; static int[] a; public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int m = input.nextInt(); a = new int[n + 1]; int[]...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
41e96c86e629ff50aeeb7de8e3267940
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** What do you think? What do you think? 1st on Billboard, what do you think of it Next is a Grammy, what do you think of it However you think, I’m sorry, but shit, I have no fucking inte...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
553d86e28cf39a0e2b89fdd5c8da2dec
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.util.*; import java.io.*; public class Main { FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); int N = (int)1e5+5, n,m,h; int[] a = new int[2*N],d = new int[N]; //set the value at given index void apply(int p,int value){ a[p] += value; ...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
bdbda916eff7b6aa92f2b8a679bfb2d3
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.util.*; import java.io.*; public class Main { FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); int N = (int)1e5+5, n,m,h; int[] a = new int[2*N],d = new int[N]; void apply(int p,int value){ a[p] += value; if(p<n) d[p] += value; } ...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
fd98c03836c3381e6d4b825bda8f3245
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.util.*; import java.io.*; public class Main { FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); int N = (int)1e5, n,m,h; int[] a,d; void apply(int p,int value){ a[p] += value; if(p<n) d[p] += value; } void build(){ for(in...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
dea54f40e87ebe6f9d72d8b15435b64c
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.util.*; import java.io.*; public class Main { FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); int N = (int)1e5+5, n,m,h; int[] a = new int[2*N],d = new int[N]; void apply(int p,int value){ a[p] += value; if(p<n) d[p] += value; } ...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
ea5829cc3404880dbaa254e2fc7e8cc9
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.util.*; import java.io.*; public class Main { FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); int N = (int)1e5, n,m,h; int[] a,d; void apply(int p,int value){ a[p] += value; if(p<n) d[p] += value; } void build(){ for(in...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
3b4c109ffb2f76cf4fea08871696517f
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; import java.io.BufferedReader; import java.util.Comparator...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
6d80cb95c24f3fda78a46b44a2d6e12f
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class Main { static final long mod=(int)1e9+7; public static void main(String[] args) throws Exception { FastReader in=new FastReader(); PrintWriter pw=new PrintWriter(System.out); int n=in.nextInt(); int m=in.nex...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
2f19ee62bfac4637faf88e750315c47a
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.io.*; import java.util.*; public class ProblemE_2 { public static InputStream inputStream = System.in; public static OutputStream outputStream = System.out; public static void main(String[] args) { MyScanner scanner = new MyScanner(inputStream); PrintWriter out = new PrintWri...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
7adbadf43556a92ca76e7dad30a06a77
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.InputMismatchException; import java.util.List; import java.util.Map; import java.util.Map.Entry; publi...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
7edba5c9dcaa50e1efd60157e2cb4214
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import javafx.scene.layout.Priority; import java.io.*; import java.lang.reflect.Array; import java.net.Inet4Address; import java.util.*; import java.lang.*; import java.util.HashMap; import java.util.PriorityQueue; public class templ implements Runnable { static class pair implements Comparable { int f...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
5c02f4d853e7377adecbc8567e5e545c
train_001.jsonl
1548254100
The only difference between easy and hard versions is a number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. The value of the $$$i$$$-th element of the array is $$$a_i$$$.You are also given a set of $$$m$$$ segments. The $$$j$$$-th segment is $$$[l_j; r_j]$$$, where $$$1 \le l_...
256 megabytes
import java.lang.*; import java.math.*; import java.util.*; import java.io.*; public class Main { void solve(){ int n=ni(),m=ni(); a=new int[n+1]; lazy=new int[4*n+1]; tree=new int[4*n+1]; for(int i=1;i<=n;i++) a[i]=ni(); build(1,1,n); int L[]=new int[m+1]; ...
Java
["5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3", "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5", "1 0\n1000000"]
2 seconds
["6\n2\n1 4", "7\n2\n3 2", "0\n0"]
NoteIn the first example the obtained array $$$b$$$ will be $$$[0, -4, 1, 1, 2]$$$ so the answer is $$$6$$$.In the second example the obtained array $$$b$$$ will be $$$[2, -3, 1, -1, 4]$$$ so the answer is $$$7$$$.In the third example you cannot do anything so the answer is $$$0$$$.
Java 8
standard input
[ "data structures", "implementation" ]
2b1595ffe5d233f788c976e155fff26f
The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 300, 0 \le m \le 300$$$) β€” the length of the array $$$a$$$ and the number of segments, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^6 \le a_i \le 10^6$$$), where $$$a_i$$$ is ...
2,100
In the first line of the output print one integer $$$d$$$ β€” the maximum possible value $$$\max\limits_{i=1}^{n}b_i - \min\limits_{i=1}^{n}b_i$$$ if $$$b$$$ is the array obtained by applying some subset of the given segments to the array $$$a$$$. In the second line of the output print one integer $$$q$$$ ($$$0 \le q \le...
standard output
PASSED
8144870eaa0cceb7fc234a4d8d0c1fef
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] s){ Scanner in = new Scanner(System.in); int numb = in.nextInt(); int data[][] = new int[numb][numb]; for (int i = 0; i < data.length; i++) { for (int j = 0; j < data.length; j++) { ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
3a03e02edff6307b09fd86fe1b270def
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } Scanner in; PrintWriter out; void run() { in = new Scanner(System.in); out = new PrintWriter(System.out); try { solve...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
45b67a84b2fa8e734eef9ac69b3c1ddf
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); int n = in.nextInt(); int a[][] = new int[n+1][n+1]; for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) a[i][j] = in.nextInt(); in...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
eb0d639c30c863c269ba91fef863d74f
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.*; import java.util.*; public class A1 { public void solve() throws IOException { int n = nextInt(); int[][] a = new int[n][n]; boolean[][] ok = new boolean[n][n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) a[i][j] = nextInt(); for (int i = 0; i < n; i++) { ok[i][i] = tr...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
1629341ce4c39b8df226de267a538a99
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.StringTokenizer; public class TaskA { BufferedReader in; PrintWriter out; StringTokenizer tokenizer; Inte...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
df544bf362ff74e08c6d80d788394cf9
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Comparator; import java.util.PriorityQueue; import java.util.Vector; public class Main { /** * @param args * @throws IOException * @throws NumberFormatExceptio...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
27f5afdaeed866b59379fc2cb1abb624
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.awt.Point; import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class Start { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer t...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
3a6a9955e5986535d59766604cecffa2
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.Scanner; public class P177A { public static void main(String[] args) { Scanner inScanner = new Scanner(System.in); int n = inScanner.nextInt(); long sum = 0; int mid = (n - 1) / 2; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
810fe9a61665bca9581e39dccd4a289a
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.*; import java.util.*; public class A { BufferedReader in; StringTokenizer st; PrintWriter out; String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine()); return st.nextToken(); } int nextInt() throws Exception { return Integer...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
6625dcce2440f4d0fbc712ecae7eb0e1
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.awt.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; /* br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); br = new BufferedReader(new InputStreamReader(System.in)); pw = new P...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
4d3127241f1c434e9edf51d00d2bba47
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; import java.io.*; public class prob { static Scanner sc; static PrintWriter pw; static int[][] a; static int n; public static void main(String[] args) { sc = new Scanner(System.in); pw = new PrintWriter(System.out); try{ n = ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
c07c02c2dcc0f687b307992ba47bf7ed
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; import java.io.*; public class ProblemA { Scanner sc = new Scanner(System.in); PrintStream out = System.out; void start() { int n = sc.nextInt(); int ans = 0; int tmp; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { tmp = sc.nextInt(); if (good(i,j,n)) ans ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
b9a9711d59d37e4295c58e8c71722cdd
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][]a = new int[n+1][n+1]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { a[i][j] = sc.nextI...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
73dbad96f5f1be8d6ef7e349fdf56642
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner theIn=new Scanner(System.in); int n=theIn.nextInt(); int[][] k=new int[n+1][n+1]; for (int i=1; i<=n; i++) { for (int j=1; j<=n; j++) { k[i][j]=theIn.nextInt(); } } long sum=0; for (int i=1; i<=n; i++) ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
9985be9a12d4a11a3e4bb6c28eb88a8f
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class A implements Runnable { private void Solution() throws IOException { int n = nextInt(); int[][] mas = new int[n][n]; boolean[][] used = new boo...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
2014db03f67377918abcd8465ce66abb
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
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[][] f = new int[n][n]; boolean[][] b = new boolean[n][n]; for (int i=0;i<n;i++) { for (int j=0;j<n;j++) { f[i][j] = in.nextInt(); if (i==j) { ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
03d1607ba4ac7dce3fa46ff0d21a6a6e
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.HashSet; import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), mid = (n - 1) / 2; long sum = 0; HashSet<String> g = new HashSet<String>(101 * 101); for (int i = 0; i < n; i++) { for (int j = 0; j < n...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
fdc6bcd60298e7b88556ec160ae993d1
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.Scanner; public class Test { public static void get(){ int n =0; Scanner s =new Scanner(System.in); n =s.nextInt(); long t =0; for (int i=0; i<n ; i++){ for (int j =0; j<n ; j++){ if (i==j|| j == n -i -1 || j == (n-1)/2 || i == (n-1)/2){ t+= s.nextInt(); } else { s...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
0accf1ec6dd98391168ea049e694fdfe
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; public class A2_177 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int a[][] = new int[n][n]; boolean visited[][] = new boolean[n][n]; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j+...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
ec103acd75423aea299a360f80065bd2
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.IOException; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Egor Kulikov (egor@egork.net) */ ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
53312e205fc2cf21c068466fddbb4a62
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; public class ABA { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[][] array = new int[N][N]; boolean[][] B = new boolean[N][N]; long ans = 0; for(int a=0;a<N;a++){ for(int b=0;b<N;b++){ array[a][b]=sc.nextInt(); } } ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
68bfa214bdbd1230d05c652a4aa09cf5
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int n = stdin.nextInt(); int[][] array = new int[n][n]; for(int i=0; i< n; ++i){ for(int j=0; j< n; ++j) { array[i][j] = stdin.nextInt(); } } long...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
7fef0e7ee8ca5cea99278a821e33ba98
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; public class Main { public void doIt(){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int [][] array = new int[n][n]; for(int i=0; i < n; i++){ for(int j=0; j < n; j++){ array[i][j] = sc.nextInt(); } } ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
acce18e2d2b6ca4d0a32eb9df0160c6f
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; import static java.lang.Math.*; import static java.lang.System.out; public class Main { Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main().A(); } void A(){ int n=sc.nextInt(); int[][] a = new int[n][n]; boolean[][] b = new boolean[n][n]; for(i...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
913b8da40f1b950f0a67c3004b63d12c
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; public class A { Scanner sc = new Scanner(System.in); void doIt() { int n = sc.nextInt(); int ans = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { int v = sc.nextInt(); if(i == j) ans += v; else if(i + j + 1 == n) ans += v; else if(i == n/2) ans += v; el...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
a12c60d274fb8e10abb37713b9c1ce5a
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; import java.io.*; public class a { public static void main(String[] args) throws IOException { boolean[] sieve = new boolean[1000001]; Arrays.fill(sieve, true); sieve[0]=sieve[1]=false; for(int i = 2; i<sieve.length; i++) if(sieve[i]) for(long j = (long)i*i; j<sieve.length; j+=i) sie...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
8ed212f359e57ce6094c756428e30800
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.Scanner; public class GoodElements { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long sum = 0; int mid = ((n-1)/2); int x = 0; for (int i = 0;i<n;i++) for (int j = 0;j<n;j++) { x=in.nextInt(); if ((i==j) || (i==mid) || (j==mi...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
973f265290b71bd1e621ff2b3383f8bb
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; public class E { static StreamTokenizer st; static PrintWriter pw; private static int...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
2cc2d318fb0800742104476e3939a347
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import static java.lang.System.out; import java.util.Scanner; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner cin = new Scanner(System.in); int n = cin.nextInt(); l...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
1d20620663f9e3c131f0e54b48264693
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.Scanner; public class Prob177A1 { public static void main(String[] Args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int sum = 0; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (i == j || i == (n - 1) / 2 || j == (n - 1) / 2 || i + j == n - 1) ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
b18eecebf05c0b327cf0f0a923bb90b0
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.FileReader; import java.io.PrintWriter; import java.util.Scanner; import java.util.Set; import java.util.TreeSet; public class Main { Scanner in; PrintWriter out; void asserT(boolean e) { if (!e) { throw new Error(); } } void solve() { int n = in.nextInt(); ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
d0e494688bb652a7d2e7d5e7c8e919e4
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class ABYE{ static BufferedReader br; public static void main(String args[])throws Exception{ br=new BufferedReader(new InputStreamReader(System.in)); int n=toInt(); int b[][]=new int[n][n]; int mid=(n+1)/2...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
d3fc4af84c1ea84547ff31d363a3c95d
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StreamTokenizer; public class A177 { static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static PrintWriter out = new PrintWriter(System.out); ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
525bdf66dac3a291fc4e90c46e331bf2
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int matrix[][] = new int[N][N]; for(int i = 0; i < N; i++){ ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
79cfb3026fcde2721ac2875c8c65b82b
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.*; import java.util.*; public class Main { BufferedReader br; public void go() throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); int n = Integer.parseInt(s); int[][] a = new int[n][n]; for (int i = 0; i < n; i++) { s ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
2f41cff6f99c5b2532d46583d942fb03
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Solution { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); StringTok...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
a0a5a06a7ecf2f4f04d224ce1cd2a1b9
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int r = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { int v = s.nextInt(); if (i == j || i == n - 1 - j || i == n / 2 || j == n / 2) { ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
00e9a546ec2a3c7ffd56cffde3fd6270
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.*; import java.util.*; public class ABBYY_A1 { /** * @param args * @throws IOException * @throws NumberFormatException */ public static void main(String[] args) throws NumberFormatException, IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new Inpu...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
2c7e3056c0f35cb0e4bc44a6e463b187
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; /** * */ /** * @author antonio081014 * @since Apr 21, 2012, 6:56:03 AM */ public class A { public static void main(String[] args) throws Exception { A main = new A(); main.run(); System.exit(0); } public void ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
9895f2c777f52aa486f8462ebb327469
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class A { ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
bc9a2656c038647a21684f34aa75a0a0
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; import java.math.*; import java.io.*; public class Main { public static void main(String args[]) throws IOException { //BufferedReader c=new BufferedReader(new InputStreamReader(System.in)); Scanner c=new Scanner(System.in); int N=c.nextInt(); int A[][]=new int[N][N]; for(int i=0;i<N;i...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
7cf0facf0d23f4f2dd3483716f1ffb3c
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; /* * * A1.java * Written by Andy Huang: 11:55:27 AM Apr 21, 2012 */ public class A1 { static void solve() { int n = in.nInt(); int sum = 0; for(int i = 0; i < n; i++){ for(int j =0; j < n; j++){ if (i == j || n-j-1 == i || i == n/2 || j == n/2) sum += in.nInt(); else ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
552d04e1de1125b87d96bd9dc2580e5e
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.Scanner; public class A1 { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int units[][] = new int[n][n]; int sum = 0; //in.next(); for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++)...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
98fa2ea5ee7907ee5cf6ff24946e5e02
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.*; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int [][] a = new int[n][n]; int d1=0,d2=0,r=0,c=0; int middle=0; for(int i =0;i<n;i++){ for(int j=0;j<n;j++){ ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output
PASSED
6a57ebffe8d76e700a2524366f31384c
train_001.jsonl
1335016800
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Elements of the main diagonal. Elements of the secondary diagonal. Elements of the "middle" row β€” the row which has exactly rows...
256 megabytes
import java.util.Scanner; public class CF_177A { /** * @param args */ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[][] val = new int[n][n]; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { val[i][j] = in.nextInt(); } } ...
Java
["3\n1 2 3\n4 5 6\n7 8 9", "5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"]
2 seconds
["45", "17"]
NoteIn the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
Java 6
standard input
[ "implementation" ]
5ebfad36e56d30c58945c5800139b880
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers aij (0 ≀ aij ≀ 100) separated by single spaces β€” the elements of the given matrix. The input limitations for getting 30 points are: 1 ≀ n ≀ 5 The input limitations for getting 100 points are: 1 ≀ n ≀ 101
800
Print a single integer β€” the sum of good matrix elements.
standard output