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
ebdcc4153319521ae1ccae05f1004f23
train_002.jsonl
1471875000
Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd.
256 megabytes
import java.util.Scanner; public class MagicOddSquare { public static void main(String[]args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a[][]=new int[n][n]; for(int i=0;i<n;i++) for(int j=0;j<n;j++) a[i][j]=0; int i=0,j=n/2; ...
Java
["1", "3"]
1 second
["1", "2 1 4\n3 5 7\n6 9 8"]
null
Java 8
standard input
[ "constructive algorithms", "math" ]
a7da19d857ca09f052718cb69f2cea57
The only line contains odd integer n (1 ≤ n ≤ 49).
1,500
Print n lines with n integers. All the integers should be different and from 1 to n2. The sum in each row, column and both main diagonals should be odd.
standard output
PASSED
97efcac6621e2a5f0bc5318af2ecfebc
train_002.jsonl
1471875000
Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd.
256 megabytes
import java.io.*; import java.util.*; public class magicOddSquare { public static void main(String args[])throws IOException { Scanner sc = new Scanner (System.in); PrintWriter out = new PrintWriter(System.out); { int n = sc.nextInt(); int mid = (n+1)/2; if (n == 1) out.println(1); ...
Java
["1", "3"]
1 second
["1", "2 1 4\n3 5 7\n6 9 8"]
null
Java 8
standard input
[ "constructive algorithms", "math" ]
a7da19d857ca09f052718cb69f2cea57
The only line contains odd integer n (1 ≤ n ≤ 49).
1,500
Print n lines with n integers. All the integers should be different and from 1 to n2. The sum in each row, column and both main diagonals should be odd.
standard output
PASSED
508bee8ab964be4ada323ba38e8444d0
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.util.Scanner; public class A { private static String replace(String s, int i, char c) { String suff = (i >= s.length() - 1)?"":s.substring(i); return s.substring(0, i) + c + s.substring(i + 1); } public static void main(String[] args) { Scanner scn = new Scanner(System...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
148de8dca52093c5ea600fc1189e8f8c
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.util.*; public class A{ public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int mapping[]=new int[9]; String actual=sc.next(); StringBuffer answer=new StringBuffer(""); for(int i=0;i<9;i++) { ...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
67ff0a2557f2ca6556779f1eac3be9f5
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.util.*; import java.math.*; public class Animal { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int f[]=new int [10]; int n=scanner.nextInt(); char []s=scanner.next().toCharArray(); String ans=new String(); for(int i=1;i<=9;i++) f[i]=scanner.nextInt(); ...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
bb5fbd57f7d875b55adad85029dfb375
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; public class Main { public void sort(long b[]){ Random rd = new Random(); for(int i=1;i<b.length;++i){ int c = rd.nextInt(i); long v = b[c]; b[c] = b[i]; b...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
a25cd9ff7b8e68eb74c2326cbba3ffca
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String[] args) throws java.lang.Exception { //Reader pm =new Reader(); Scanner pm = new Scanner(new BufferedReader(new InputStreamReader(System.in))); int t = 1; while(t-- ...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
ba3eb7ebcf7fb27c31803ee22e82d0a5
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.util.*;public class S{public static void main(String[]g){Scanner s=new Scanner(System.in);int n=s.nextInt(),c=0,a;char[]b=s.next().toCharArray(),f=new char[58];for(int i=1;i<10;i++)f['0'+i]=((char)('0'+s.nextInt()));for(int i=0;i<n;i++)if(f[a=b[i]]>a|f[a]==a&c>0){c=1;b[i]=f[a];}else if(c>0)break;System.out....
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
18b2b34d930fef8eaca66fad9fc57dd3
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.util.*;public class S{public static void main(String[]g){Scanner s=new Scanner(System.in);int n=s.nextInt(),c=0,a;StringBuilder b=new StringBuilder(s.next());char[]f=new char[256];for(int i=1;i<10;i++)f['0'+i]=((char)('0'+s.nextInt()));for(int i=0;i<n;i++)if(f[a=b.charAt(i)]>a|f[a]==a&c>0){c=1;b.setCharAt(i...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
b516f4e5b04c4827a410d286e87a7af5
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.util.*;public class S{public static void main(String[]g){Scanner s=new Scanner(System.in);int n=s.nextInt(),c=0,a;StringBuilder b=new StringBuilder(s.next());int[]f=new int[10];for(int i=1;i<10;i++)f[i]=s.nextInt();for(int i=0;i<n;i++)if(f[a=Character.getNumericValue(b.charAt(i))]>a||f[a]==a&&c>0){c=1;b.rep...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
fc083b6319615d02515c10bd8208594f
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(), c = 1; String t = s.next(); int[] f = new int[10]; for (int i = 1; i < 10; i++) f[i] = s.nextInt(); StringBuil...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
3147b1780e8e8b750e0dad235f90054a
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class atharva { InputStream is; PrintWriter out; long mod = (long)(1e9 + 7), inf = (long)(1e18); class pair { long A, B; pair(long a, long b) { A = a; B = b; } } static long gcd(long a, l...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
8bba0620717fc3ad2936b68250d1b56b
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.io.*; import java.util.*; public class Main { static PrintWriter pw; public static void main(String[] args) { Scanner sc = new Scanner(System.in); pw = new PrintWriter(System.out); int poo=sc.nextInt(); char[] s = sc.next().toCharArray(); int []a=new int[10]; ...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
31a40ddb97e643c84d662b5940ab179e
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.io.*; import java.lang.*; import java.util.*; import java.math.BigInteger; public class MapLargestNumber { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long digitsOfA = Long.parseLong(sc.next()); String strNum = sc.next(); //System.out.println("inpu...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
4ca48be0dffe38e75639755a61d215fa
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class cf1557b { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
2095ecbea03c55e58b0932bcc8e4f07f
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.util.*; public class longNumber { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s=new Scanner(System.in); int n=s.nextInt(); String str=s.next(); int fun[]=new int[10]; for(int i=1;i<10;i++) fun[i]=s.nextInt(); int first=-1,last=-1; ...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
0c03fece0286b4c12a2dc3d970df97f0
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.io.*; import java.util.*; public class Task { static int[] f; public static void solve(int testNumber, Scanner in, PrintWriter out) { int n = in.nextInt(); StringBuilder s = new StringBuilder(in.next()); StringBuilder ans = new StringBuilder(); f = new int[10]; ...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
09f34ce76311d8d18b984790c6c15e14
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.util.*; public class Class{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=Integer.parseInt(sc.nextLine()); String x=sc.nextLine(); String y=(sc.nextLine().replaceAll(" ","")); StringBuilder ans=new StringBuilder(); boolea...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
03bc0dcd764ca197b37098455f0c1f6c
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.util.*; public class Class { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=Integer.parseInt(sc.nextLine()); String s=sc.nextLine(); String fx=sc.nextLine().replaceAll(" ",""); StringBuilder ans=new StringBuilder(); boolean flag=false; for(int i=0;i<s.lengt...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
7e22b3af072d14805ab44b455328ecd4
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.io.PrintWriter; import java.util.*; /** * Created by Andrey on 17.02.2019. */ public class TaskD1 { static final double PI = 3.14159265359; void solve(Scanner in, PrintWriter out) { int n = in.nextInt(); in.nextLine(); String st = in.nextLine(); char[] f = new ...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
f0561fcb30b1eb49207dbc3c18f1fd46
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * * @author Haya */ public class LongNumber { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(Sy...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
c0a51184ad21aac48b575bde87934ef2
train_002.jsonl
1556289300
You are given a long decimal number $$$a$$$ consisting of $$$n$$$ digits from $$$1$$$ to $$$9$$$. You also have a function $$$f$$$ that maps every digit from $$$1$$$ to $$$9$$$ to some (possibly the same) digit from $$$1$$$ to $$$9$$$.You can perform the following operation no more than once: choose a non-empty contigu...
256 megabytes
import java.util.*; public class Num2 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); int n = scan.nextInt(); char[] c = scan.next().toCharArray(); int[] f = new int[10]; for (int i = 1; i <= 9; i++) f[i] = scan.nextInt(); int i ...
Java
["4\n1337\n1 2 5 4 6 6 3 1 9", "5\n11111\n9 8 7 6 5 4 3 2 1", "2\n33\n1 1 1 1 1 1 1 1 1"]
2 seconds
["1557", "99999", "33"]
null
Java 8
standard input
[ "greedy" ]
378a9ab7ad891d60f23645106d24f314
The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of digits in $$$a$$$. The second line contains a string of $$$n$$$ characters, denoting the number $$$a$$$. Each character is a decimal digit from $$$1$$$ to $$$9$$$. The third line contains exactly $$$9$$$ integers $$$f(1)$$$, $$...
1,300
Print the maximum number you can get after applying the operation described in the statement no more than once.
standard output
PASSED
c20822873bc146dc3512b4a4dbbbe8b9
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.*; import java.io.*; public class Main { static class Scan { private byte[] buf=new byte[1024]; private int index; private InputStream in; private int total; public Scan() { in=System.in; } public int scan()throws IOExcepti...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
989fd26a0bfff1069aef4f31a9b8dddc
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) throws Exception { // Your code here! Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(),m=sc.nextInt(); int a[][]=new in...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
5c6bf252048c1924a87268dcab64088a
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
//package dataStructures; import java.util.*; import java.lang.*; import java.io.*; public class test1 { static long mod = 1000000007; public static void main (String[] args) throws IOException { FastReader sc = new FastReader(); int t = sc.nextInt(); StringBuffer ans = new StringBuffer(""); while(t-->0...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
107351219ae72fda463a813f556cefee
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
/*input 2 4 2 4 2 2 4 4 2 2 4 3 4 1 2 3 4 5 6 7 8 9 10 11 18 3 1 4 1 2 9 2 4 1 2 2 3 3 2 2 2 2 10 2 4 2 4 2 2 4 4 2 2 4 3 4 1 2 3 4 5 6 7 8 9 10 11 18 */ import java.util.*; public class Easy3{ public static <Type> void print(Type val) { System.out.println(val); } public static <Type> String printArr(Type val[])...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
020a20ee53a79bf7553f89709af36140
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.io.*; import java.util.*; import static java.util.Collections.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf { private static final int MOD = (int) (1e9 + 7), MOD_FFT = 998244353; private static final Reader r = new Reader(); private static final PrintWri...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
0b80a2736eb2cd21995d7c17b6a02d56
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; public class Main { static final int INF = (int) (1e9 + 10); static final int MOD = (int) (1e9 + 7); // static final int N = (int) (4e5 + 5); // static ArrayList<Integer>[] graph; // static boolean visited[]; // st...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
336bbe0d39a4cefd140a3934fbd4e9b9
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.*; import java.io.*; public class codeforces{ public static void main(String args[]){ codeforces s=new codeforces(); Scanner sc=new Scanner(System.in); for (long t = sc.nextInt(), sum=0; t-- > 0; sum=0) { int n = sc.nextInt(), m = sc.nextInt(), a[][] = new int[n][m]; for (int i = 0; ...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
2056561de5c83c85ad8f1e6e97db3593
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.*; public class nice { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while (T-->0){ int N = sc.nextInt(); int M = sc.nextInt(); int[][] grid = new int[N][M]; int[][] orig...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
f743654ee69e85645ec719d935121a12
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import java.util.stream.Collectors; public class SolutionB extends Thread { static class FastReader { BufferedReader br; StringTokenizer st; public F...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
3f8574c6828a342d384a1f508aa5034f
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int tc = s.nextInt(); for(int t = 0;t < tc;t++) { int n = s.nextInt(); int m = s.nextInt(); int[][] input = new in...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
204212951f7d05ba165efe305680fe0f
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); outer: while (t-- > 0) { int n = sc.nextInt(); ...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
ef16b3a347d1ecf33ac06f535d352cb3
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.*; import java.io.*; public class codeforces{ public static void main(String args[]){ //codeforces s=new codeforces(); Scanner sc=new Scanner(System.in); for (long t = sc.nextInt(), sum=0; t-- > 0; sum=0) { int n = sc.nextInt(), m = sc.nextInt(), a[][] = new int[n][m]; for (int i = 0; i ...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
3a15fbf9859cff2f3cfa1bd13b5b3229
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.*; import java.io.*; public class codeforces{ public static void main(String args[]){ codeforces s=new codeforces(); Scanner sc=new Scanner(System.in); for (long t = sc.nextInt(), sum=0; t-- > 0; sum=0) { int n = sc.nextInt(), m = sc.nextInt(), a[][] = new int[n][m]; for (int i = 0; i < ...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
8da2f6f315b4f702276074c4e708aca2
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
//package Codeforces.Round675Div2; import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws IOException { Soumit sc = new Soumit(); int t = sc.nextInt(); while (t-->0) { int n = sc.nextInt(); int m = sc.nextInt()...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
395a15227a1cd6259a62599fedd29001
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
// package oct2020; import java.util.*; import java.lang.*; import java.math.*; import java.io.*; public class cf_subs { static FastReader scn = new FastReader(); static OutputStream out = new BufferedOutputStream(System.out); public static void main(String[] args) throws IOException { // TODO Auto-generated met...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
50ccc161514ecbc2e9ac140458a96fa5
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.io.*; import java.util.*; public class noob { InputReader in; final long mod=1000000007; StringBuilder sb; public static void main(String[] args) throws java.lang.Exception { new noob().run(); } void run() throws Exception { in=new InputReader(System.in); sb =...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
171a43d0d69289eac78192ab54f4374d
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public final class NiceMatrix{ private long med(long[] m){ assert m.length == 4; Arrays.sort(m); return (m[1] + m[2])/2; } private long median(long[][] m, int rb, int re, int cb, int ce){ { long _median = (rb == ...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
410ab4e1b5d3d510b9e074e25cd522de
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { long mod1 = (long) 1e9 + 7; int mod2 = 998244353; public void solve() throws Exception { int t = sc.nextInt(); while (t-- > 0) { int n=sc.nextInt()...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
c29379ab54c3d3a82f0f0e76b0bb04b8
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.*; import java.io.*; public class Main{ static class Point{ int x, y, z, i; Point(int nx, int ny){x = nx; y = ny; } } public static void main(String[] args) throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int q = pint(in); for(; q > 0; q--) {...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
b857d3883c3aa42a91f481ff2849377e
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.*; public class Solution{ static Scanner sc = new Scanner(System.in); public static void main(String args[]){ int t = sc.nextInt(); while(t-->0){ int m = sc.nextInt(),n = sc.nextInt(); int mat[][] = new int[m][n]; for(int i=0;i<m;i++) for(int j=0;j<n;j++) mat[i][j] = sc.nextInt(...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
e7e4f07d1801cf20badaa64541b6ed57
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.*; public class Solution{ static Scanner sc = new Scanner(System.in); public static void main(String args[]){ int t = sc.nextInt(); while(t-->0){ int m = sc.nextInt(),n = sc.nextInt(); int mat[][] = new int[m][n]; for(int i=0;i<m;i++) for(int j=0;j<n;j++) mat[i][j] = sc.nextInt(...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
951652e735e99a98d413cdc2ca2cda79
train_002.jsonl
1601827500
A matrix of size $$$n \times m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, \dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 \le i \le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds.Sasha owns a matrix $$$a$$$ of size $$$n \times m$$...
256 megabytes
import java.util.*; public class Code { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int m=sc.nextInt(); int arr[][]=new int[n][m]; for(int i=0;i<n;i++) { for(int j...
Java
["2\n4 2\n4 2\n2 4\n4 2\n2 4\n3 4\n1 2 3 4\n5 6 7 8\n9 10 11 18"]
1 second
["8\n42"]
NoteIn the first test case we can, for example, obtain the following nice matrix in $$$8$$$ operations:2 24 44 42 2In the second test case we can, for example, obtain the following nice matrix in $$$42$$$ operations:5 6 6 56 6 6 65 6 6 5
Java 11
standard input
[ "implementation", "greedy", "math" ]
5aa709f292f266799f177b174c8bc14b
The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10$$$). The $$$t$$$ tests follow. The first line of each test contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the size of the matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i, j}$$$...
1,300
For each test output the smallest number of operations required to make the matrix nice.
standard output
PASSED
0de65f2deffb463bfc515c329264ec2c
train_002.jsonl
1267117200
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
64 megabytes
/** * ******* Created on 17/9/19 9:29 PM******* */ import java.io.*; import java.util.*; public class ACon2 { public static void main(String[] args) throws IOException { final class Pair{ String a; int b; public Pair(String a , int b){ this.a =a; ...
Java
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
1 second
["andrew", "andrew"]
null
Java 8
standard input
[ "implementation", "hashing" ]
c9e9b82185481951911db3af72fd04e7
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
1,500
Print the name of the winner.
standard output
PASSED
3dc6976bdb36682181411711fd9ea8fc
train_002.jsonl
1267117200
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
64 megabytes
import java.util.*; public class Main { public static void main(String[] args) { int[] ar = new int[1010]; String[] st = new String[1010]; HashMap<String,Integer> map = new HashMap<String,Integer>(); HashMap<String,Integer> hash = new HashMap<String,Integer>(); int n; Scanner scan = new Scanner(System.in); n = ...
Java
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
1 second
["andrew", "andrew"]
null
Java 8
standard input
[ "implementation", "hashing" ]
c9e9b82185481951911db3af72fd04e7
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
1,500
Print the name of the winner.
standard output
PASSED
cc22005dcff48007afd2ea5b5edc5f97
train_002.jsonl
1267117200
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
64 megabytes
import java.util.*; public class Main { public static void main(String[] args) { HashMap<String,Integer> map = new HashMap<String,Integer>(); LinkedHashMap<Integer,String> hash = new LinkedHashMap<Integer,String>(); int use = Integer.MIN_VALUE; int max = Integer.MIN_VALUE; Scanner scan = new Scanner(System.in); ...
Java
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
1 second
["andrew", "andrew"]
null
Java 8
standard input
[ "implementation", "hashing" ]
c9e9b82185481951911db3af72fd04e7
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
1,500
Print the name of the winner.
standard output
PASSED
6d0cea2d031211fa9ff017a981cf27e8
train_002.jsonl
1267117200
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
64 megabytes
import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Winner { public static class Player { public int score; public ArrayList<ArrayList<Integer>> record; public Player() { record = new ArrayList<ArrayList<Integer>>(); score = 0; } ...
Java
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
1 second
["andrew", "andrew"]
null
Java 8
standard input
[ "implementation", "hashing" ]
c9e9b82185481951911db3af72fd04e7
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
1,500
Print the name of the winner.
standard output
PASSED
ffd841e043919cb1639b200ca21f889a
train_002.jsonl
1267117200
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
64 megabytes
import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Winner { public static class Player { public int score; public ArrayList<ArrayList<Integer>> record; public Player() { record = new ArrayList<ArrayList<Integer>>(); score = 0; } ...
Java
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
1 second
["andrew", "andrew"]
null
Java 8
standard input
[ "implementation", "hashing" ]
c9e9b82185481951911db3af72fd04e7
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
1,500
Print the name of the winner.
standard output
PASSED
1c9e6c7d5d39deca38de95523b9ec7cb
train_002.jsonl
1267117200
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
64 megabytes
import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Winner { public static class Player { public int score; public ArrayList<ArrayList<Integer>> record; public Player() { record = new ArrayList<ArrayList<Integer>>(); score = 0; } ...
Java
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
1 second
["andrew", "andrew"]
null
Java 8
standard input
[ "implementation", "hashing" ]
c9e9b82185481951911db3af72fd04e7
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
1,500
Print the name of the winner.
standard output
PASSED
39aac80c171abba6e1b4561235f2b8cb
train_002.jsonl
1267117200
The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation becomes more difficult if the number of such players is more than one. During each round a pla...
64 megabytes
import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan=new Scanner(System.in); HashMap<String,Integer> map=new HashMap<>(); int n=scan.nextInt(); int max=Integer.MIN_VALUE; String ans=""; String [] name1=new String [n]; int[] score1=n...
Java
["3\nmike 3\nandrew 5\nmike 2", "3\nandrew 3\nandrew 2\nmike 5"]
1 second
["andrew", "andrew"]
null
Java 8
standard input
[ "implementation", "hashing" ]
c9e9b82185481951911db3af72fd04e7
The first line contains an integer number n (1  ≤  n  ≤  1000), n is the number of rounds played. Then follow n lines, containing the information about the rounds in "name score" format in chronological order, where name is a string of lower-case Latin letters with the length from 1 to 32, and score is an integer numbe...
1,500
Print the name of the winner.
standard output
PASSED
c7d2c178465a0d65ee6dec223985706c
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] trees = new int[n]; for (int i = 0; i < n; i++) { trees[i] = scan.nextInt(); } int currentHeight = 0; ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
5d09d40694945777b1a5d64f89a0b08c
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.math.BigInteger; import java.util.ArrayList; import java.util.Scanner; public class B { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = s.nextInt...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
b8b3670c2db17bb60d3e12d332f54193
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer sb=new S...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
fb33e5b6cb4385ada5a9863a7bdfa2a0
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.*; /** * Write a description of class b here. * * @author (your name) * @version (a version number or a date) */ public class b { public static void main(String[] args) { Scanner input = new Scanner(System.in); int num = input.nextInt(); int total = 0; int...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
a25604f7df4e3889a445d44a63f04d9f
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.PriorityQueue; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
0f823ab5b52c703e006787e27750c13d
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.InputStreamReader; import java.util.Scanner; public class Round_162B { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner r = new Scanner(new InputStreamReader(System.in)); int n = r.nextInt(); int[]...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
8f4549c832a7cff1e7cd55b56bcbd895
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.*; public class cf265b { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] v = new int[n]; for(int i=0; i<n; i++) v[i] = in.nextInt(); int ans = n+n-1+v[0]; for(int i=1; i<n; i++) ans += Math.abs(v[i]-v[i-1]);...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
8fe0ebdbf574bfbfe4845b46c6109323
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String args[]) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = t_int(br); int[] t = new int[n]; for (int i = 0; i < n; i++) { t[i] = t...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
72aeee56371a206609a673b3b04ee199
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; public class Solution265B{ public Solution265B() { } public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int height = 0; int pos = 0; int total = 0; for(int i = 0 ; i < n ; i++) { if(pos != 0) total += 1; heigh...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
a62232b8ca4924b508d3ed287d2155b8
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; public class P265B { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] h = new int[n]; for (int i = 0; i < n; i++) { h[i] = scanner.nextInt(); } long cost = 2 * n - 1; int ch = 0; for (...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
8cfefcb5479ececaa7a4be234488aa08
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
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 = n...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
25c61fea854bad05f32de8533d409180
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class taskA { Scanner in; PrintWriter out; void solve() { int n = in.nextInt(); int time = 0; int pred = in.nextInt(); time += pred; time++; for (int i = 1; i < n; i++) { int sled = in.nextInt(); if(pred <=...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
f86f46515c453ec5b906342b10dbe34a
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Administrator */ public class b { Scanner cin = new Scanner(System.in); int a[] = new int [111111]; void run(){ int n; while(cin.hasNext()){ ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
8f2ac44e365a3b206d5d92fdf455f084
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.*; import java.io.*; public class second162 { public static void main(String[] args)throws IOException { BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); //Scanner sc = new Scanner(System.in); int n = Integer.parseInt(rd.readLine()); StringT...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
fde037e428332e1907d8494c0756fb90
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
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.util.StringTokenizer; public class B { static StringTokenizer st; static BufferedReader in; public sta...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
72c2ad54abe64ea19ef170ebf73a46e9
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; public class New { public static void main(String[] args) { Scanner bahy = new Scanner(System.in); int num = bahy.nextInt(); int[] hight = new int [num]; for(int n=0;n<num;n++) { hight[n]=bahy.nextInt(); } int sum= hight[0]+1; for(int y=1;y<num;y++) {...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
3d29a8cbfafc6cbff163713adde5ddf0
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class D2B { public void solve(){ PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int ans = 0; int curr...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
d4a2cb31771da2af94e19f5e4925f90a
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.*; import java.math.*; public class solve{ public static void main(String args[]){ Scanner scanner = new Scanner(System.in); Integer n = scanner.nextInt(); Integer[] mas = new Integer[n]; mas[0] = scanner.nextInt(); Long seconds = new Long(0); for(in...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
673172bffdf837a2c65bc14b481b91e9
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.BufferedInputStream; import java.util.*; import static java.lang.Math.*; public class C264B { public void solve() throws Exception { int n = nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = nextInt(); } int res = n + n - 1; int akt = 0; for (int i = 0; i < a...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
38777ce1d5f9e0ca963048bdef0a1a19
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
/** * Created with IntelliJ IDEA. * User: yuantian * Date: 3/8/13 * Time: 1:04 AM * To change this template use File | Settings | File Templates. */ import java.util.*; public class RoadsideTreesSimplifiedEdition { public static void main(String[] args) { Scanner in = new Scanner(System.in); ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
9ec9bbee757ffe8b7c9c29b0b0be7773
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; public class RoadsideTrees { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int numberOfTrees = sc.nextInt(); int[] trees = new int[numberOfTrees]; for (int i = 0; i < trees.length; i++) { trees[i] = sc.nextInt()...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
2d537c158321e1c31e228aab15e0f77a
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
179d691abe3acfe13626541cbdf0851e
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.*; public class B { public static void main (String[]ar)throws Exception{ BufferedReader read = new BufferedReader (new InputStreamReader(System.in)); int trees = Integer.parseInt(read.readLine()); int[] t = new int[trees]; for(int i=0;i<trees;i++) ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
e7b8c9afbd64fe9f9145e7129ccffc0b
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int arr[]=new int[n]; int time=0; int h=0; for (int i = 0; i < arr.length; i++) { arr[i]=scan.nextInt(); if(i==0){ time+=1+arr[0]; h=arr[0...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
0eb1642b01db896ec9a0720ab130cc65
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.*; public class nut { public static void main(String[] args) { Scanner k=new Scanner(System.in); int tree=k.nextInt(); int[] array=new int[tree]; int second=0; int before=0; for (int i = 0; i < tree; i++) { array[i]=k.nextInt(); if (i==0) { ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
ac4258c12aa016f0f50af1faf4ad642b
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; Outpu...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
0a0549eda6361b580038525885da0f30
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.*; public class CF162B{ public static void main(String args[]) throws IOException { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); String line = stdin.readLine(); int n = Integer.parseInt(line); int[] h = new int[n]; for(int i=0; i<n; i++){ ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
80cca67cdc13177e1db3e841add60044
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.*; public class Main { public static void main(String args[]) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int h[] = new int[n]; for (int i = 0; i < n; i++) h[i] = in.nextInt(); int steps = 0; steps = steps + h[0] + 1; // ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
49711e7ba6a10c9a45dca47e7d624283
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.PriorityQueue; import java.util.ArrayList; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
24a73b2ee110d24a25a7bc0dc41dc982
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
/* PROG: b LANG: JAVA */ import java.util.*; import java.io.*; public class b { private void solve() throws Exception { //BufferedReader br = new BufferedReader(new FileReader("b.in")); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
eb0a86abcb5255dfcef0218ca50a8d94
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.File; import java.io.PrintWriter; import java.util.Scanner; public class CF199A { public static void main(String[] args) throws Exception{ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int pos = 0; long total = N+N-1; for(int a=0;a<N;a++){ int cur = sc.nextInt(); total+=Ma...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
855338f9232e2fa8fe6c113b4c49fbe1
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import static java.lang.Math.*; import java.io.*; import java.math.BigInteger; import java.util.*; public class one implements Runnable { public void run() { int n = nextInt(); int[] h = new int[n]; for (int i = 0; i < n; i++) { h[i] = nextInt(); } long ans = h[0] + 1; for (int i = 1; i < n; i++) { ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
e6766255b0220e5e633c8f3f0924b597
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * Created by IntelliJ IDEA. * User: prasoon.m * Date: 1/20/13 * Time: 7:05 PM * To change this template use File | Settings | File Templates. */ public class Main { public static void main(String[] args) throws I...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
9a2d738d95191ea1cf6024e66e26ee37
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public final class Ideone { public static void main (String[] args) throws java.lang.Exception { Scanner in = new Scanner...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
83b858db78bdc76bd06c169d1b0ab892
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.*; public class Main{ void solve(){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] h = new int[n]; for(int i=0; i<n; i++) h[i] = sc.nextInt(); int height = h[0]; int cnt = 1+h[0]; for(int i=1; i<n; i++){ if(h[...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
dddebb38b3f5265357efeb26b3b416c2
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Ziklon */ public class Main { public static void main(String[] args) { InputStream input...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
eee49b891c7731244bdb8c8a0e29ac48
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; public class TreesAlongTheRoad { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int prev = sc.nextInt(); int sum = prev + 1; for (int i = 1; i < n; i++) { int cur = sc.nextInt();...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
ff21545d9a5f2b6ab6a62cfcabf7024c
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class nuts { public static void main(String[] args) throws IOException { BufferedReader cin=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(cin.readLine()); int f=n; int ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
4818cd62e5466174977dff06f9ea1fc2
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int currentHeight = 0; int time = 0; for(int i = 0; i < n; i++) { int height = scan.nextInt(); time...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
759239805c002448d226218e50a8a2c4
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Scanner; public class B162 { public void solve() throws IOException { Scanner sc = new Scanner(System.in); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int i = 0, j = 0; int n = sc.nextIn...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
76a2b2ab7e6214f7ddf918bec69a3d09
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.*; import java.math.*; import java.io.*; public class b2 { public static void main(String[] args) throws IOException { input.init(System.in); int n = input.nextInt(); int[] data = new int[n]; for(int i =0; i<n; i++) data[i] = input.nextInt(); long res = data[0]; for(int i = 1; i...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
40ae82551f6680dbd00218f2c935d941
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.*; /** * * @author DHA */ public class JavaApplication1 { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { // TODO code application logic here int n,h = 0; BufferedReader r = new BufferedRe...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
2aead2ab6bc838db4e0fb2110bbe1c8a
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.BigInteger; public class Main{ //for(Map.Entry<Object, Object> e: map.entrySet()){ ... public static void main(String[] args){ try{ //-*-*- tp start -*-*- final int INF = Integer.MAX_VALUE, MINF = Integer.MIN_VALUE; ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
f2828400b800256080f2d3f225d1feaa
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; public class JavaApplication16{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[n+2]; for(int k=1;k<=n;k++){ a[k]=sc.nextInt(); } int q=0; for(int k=1;k<n;k++){ if(k==1){ q=a[k]+1; if(a[k]>a[k+1]){ q=q+a[k]-a[k+1]+2; ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
cf27ed6de5b7cc6b74723eab80b72ef7
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; public class B implements Runnable { private void solve() throws IOException { int n = nextInt(); lon...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
18512edbad884462d306c779f041fa9c
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.*; public class d2_162_B { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int n=sc.nextInt(); // int a[]=new int[n]; // int b[]=new int[n]; // for(int i=0;i<n;i...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
eba723e1c6146dc6d92728dec3395c5f
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.*; public class RoadsideTrees { public static void main(String[] args) { int n; int count = 0; int tmp; int curHeight = 0; Scanner input = new Scanner(System.in); n = Integer.parseInt(input.nextLine()); for (int i = 0; i < n; i++) { tmp = Integer.parseInt(input.nextLine()); if(i ==...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
d37479ac4048802907778cf3865c72e2
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.*; public class problem2 { public static void main(String[]args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[]h=new int[n]; for(int i=0;i<n;i++) { h[i]=sc.nextInt(); } int s=n+h[0]; for(int j=1;j<n;j++)...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output
PASSED
8afff128bbe99dbccd4709c4d5bd4583
train_002.jsonl
1358686800
Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is hi. Liss wants to eat all nuts.Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actio...
256 megabytes
import java.util.Scanner; public class CodeforcesRound162B { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner kde=new Scanner(System.in); int n=kde.nextInt(); int[] h= new int[n]; for(int i=0; i<n; i++ ) { ...
Java
["2\n1\n2", "5\n2\n1\n2\n1\n1"]
2 seconds
["5", "14"]
null
Java 6
standard input
[ "implementation", "greedy" ]
a20ca4b053ba71f6b2dc05749287e0a4
The first line contains an integer n (1  ≤  n ≤ 105) — the number of trees. Next n lines contains the height of trees: i-th line contains an integer hi (1 ≤ hi ≤ 104) — the height of the tree with the number i.
1,000
Print a single integer — the minimal time required to eat all nuts in seconds.
standard output