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
7dd6d535dc31a08a80131042d7c7ee8b
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Housni Abdellatif */ public class Main { public static void main(String[] args) { Inp...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
d29c0dafa982a0bcce9b31cd34c6e880
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.util.*; import java.io.*; public class solution { public static void merge(int arr[], int l, int m, int r) { // Find sizes of two subarrays to be merged int n1 = m - l + 1; int n2 = r - m; /* Create temp arrays */ int L[] = new int [n1]; int R[] = new...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
b16c297cd690a81e992bfd32f1a6de78
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.util.ArrayList; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Arrays; import java.util.Random; import java.io.FileWriter; import java.io.PrintWriter; /* Solution Created: 18:21:56...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
a71beb35672ee60604bb13b07a8a8c30
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i < t; i++) { int n = sc.nextInt(); long inp[] = new long[n]; for(int j = 0; j < n; j++) { ...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
2c115341786d9612ce97403cfd9f7aa0
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.text.*; /* Name of the class has to be "Main" only if the class is public*/ public class cf_1343C { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br =...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
9cb2381f000f335d5c05093592aaa830
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.text.*; /* Name of the class has to be "Main" only if the class is public*/ public class cf_1343C { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br =...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
ce79bf7b46a68ae83867700c073c767d
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.io.*; import java.util.*; public class Q1 { public static void main(String[] args) { InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out); int t = in.nextInt(); while (t-- > 0) { int N = in.nextInt(); int arr[] = ...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
831885c427b48c3e04b1e3b0218633b0
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { ...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
8a17137dc954e358184901639b565d38
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.util.Scanner; public class Sequence { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int cases = sc.nextInt(); for(int i=1; i<=cases; i++){ int elements = sc.nextInt(); int[] num = new int[elements]; long sum =0L; ...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
23e1fc50cad9cc0961db6cbcaa0a7eae
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while (t-- > 0) { long n, mi = Long.MIN_VALUE, ma = 0; int flag = 0, flag1 = 0; n = in.nextLong(); lon...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
991471350f5f4bd49d43d857cf1bea6e
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class AlternatingSubsequence { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while (t-- > 0) { int n = scn.nextInt(); long[] arr = new long[n]; ...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
1a55380831a0dfee37c68c95089aaaaf
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.io.*; import java.util.*; public class Solution { public static void main(String args[]) { FastReader sc=new FastReader(); int t=sc.nextInt(); int i=0,j=0,k=0; for (int testcase=0;testcase<t;testcase++) { long n=sc.nextInt(); long arr...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
9d99b32df26cf5317d4216d98d203784
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.io.*; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.StringTokenizer; public class Main { static int MAXN=201; static int spf[] = new int[MAXN]; static int ans[]=new int[MAXN]; static int id[]=new i...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
0ac0867886e10ac1bd03169f2cebd85a
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
// I know stuff but probably my rating tells otherwise... // Kaafi din baad aaye hai... Swagat nhi kariyega??? // Kya hua, code samajhne ki koshish kar rhe ho?? Mat karo, // mujhe bhi samajh nhi aata kya likha hai import java.io.*; import java.util.*;...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
1531bee46a4af75ff8c2ad007329172b
train_002.jsonl
1587479700
Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseIn...
Java
["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"]
1 second
["2\n-1\n6\n-2999999997"]
NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,...
Java 11
standard input
[ "dp", "two pointers", "greedy" ]
39480cdf697fc9743dc9665f989077d7
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$...
1,200
For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$.
standard output
PASSED
c66027b95d77e9b5d7e7a0dbb0915ead
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; import java.io.*; public class a { public static void main(String[] arg) throws IOException { new a(); } public a() throws IOException { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int[] vs = new int[n]; for(int i ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
25a138c0fdd2618f9481c6b023f26d2b
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; public class HolidayOfEquality { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { long noOfCitizens = sc.nextLong(); long max = 0; long ans = 0; long arr[] = new long[(int) noOfCitizens]; for(int i = 0 ;i <noOfCitizens ;i++) arr[i] = sc.nex...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
e1ca9a3e4c08aea645e24039dd93d3d7
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
//package codeforces; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int [] in = new int [n]; int max = in[0]; int min = in[0]; int d=0; int sum = 0; for (int y = 0 ; y < n...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
614b143186898494e7b48a9882890a44
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String arg[]) { FastScanner sc = new FastScanner(System.in); int n = sc.nextInt(); int x [] = new int [n]; int sum= 0,o=0; while (n-->0){ x[o++] = sc.nextInt(); } in...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
46397e8f68731f10b4c1911a226064c6
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String arg[]) { FastScanner sc = new FastScanner(System.in); int n = sc.nextInt(); int x [] = new int [n]; int sum= 0,o=0; while (n-->0){ x[o++] = sc.nextInt(); } ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
8fcdddffb6415fe82248c641a17997af
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String arg[]) { FastScanner sc = new FastScanner(System.in); int n = sc.nextInt(); int x [] = new int [n]; int sum= 0,o=0; while (n-->0){ x[o++] = sc.nextInt(); } Ar...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
ae895df54f63eafe77a4040e248583d4
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); String n1 = input.nextLine(); String num = input.nextLine(); int n=Integer.parseInt(n1); if (n==0){ System.out....
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
0380b101112f10b2087f6dbaf62d887d
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Question758A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] arr = new long[n]; long max=0; for (int i = 0; i < n; i++) { arr[i] = sc.nex...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
48888aa23d9c6b7be85a61fe8efc97e7
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Question758A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] arr = new long[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextLong(); } ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
9e4fce132706a15fb90b7c7a147b6638
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.Arrays; import java.util.Scanner; public class TestApplication { public static void main(String[] args) { ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
250fda88c4bba204ae51072aa71c6735
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.Scanner; public class TestApplication { public static void main(String[] args) { Scanner scanner = new...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
f8f9badfc177b1a53d4d34ca5f6de059
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n,i,max; n = in.nextInt(); int arr[]= new int[n],sum = 0; for (i=0; i<n; i++) arr[i] = in.nextInt(); Arrays.sort(arr); max = arr[n-1]; ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
6fc2348c059af3b1db1b57aa5e5f1785
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n,i,max; n = in.nextInt(); int arr[]= new int[n],sum = 0; for (i=0; i<n; i++) arr[i] = in.nextInt(); Arrays.sort(arr); max = arr[n-1]; f...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
7436f6ea0b1178eac55d0b2c7fa71478
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; import java.io.*; public class Holiday{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int numofloop = sc.nextInt(); int[] arrnum = new int[numofloop]; int i=0,j=0,sum=0; sc.nextLine(); while(numofloop>0){ ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
32918b6c0cf27907e132ad5e07c09117
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.lang.reflect.Array; import java.util.Arrays; import java.util.Scanner; public class HolidayOfEquality { public static void main(String[] args) { Scanner in= new Scanner(System.in); int n,sum=0,max,max_sum; n=in.nextInt(); int a[]=new int[n]; ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
7e9463f35451326d8ca96e45b82692fd
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] arr=new int[n]; for(int i=0;i<n;i++) arr[i]=...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
4be6f3e7462a94bc38db699e68814321
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=sc.n...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
672e9caba7cf2941d7743704f1d0c100
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Scanner; public class Pockets { public static void main(String[] args) { int n = 0; int []a = new int[101]; int max = 0; int total = 0; int i; Scanner in = new Scanner(System. in); n = in.nextInt(); for (i = 0; i < n; i++) { a[i] = in.nextInt(); } for(i = 0; i < n...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
a534dc226d6ce7ad6ad676aa60104575
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Scanner; import java.util.Arrays; public class HolidayOfEquality{ public static void main(String[] args){ Scanner input = new Scanner(System.in); int numOfCitizens = Integer.parseInt(input.nextLine().trim()); String[] parts = input.nextLine().split("\\s+"); int[] welfare = new int[parts.len...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
97109c9cc23f8940a3e4ae49c7a64f17
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.io.*; import java.util.*; public class soultion { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); int i,max=0,cnt=0; int[] a=new int[n]; for(i=0;i<n;i++) a[i]=s.nextInt(); for(i=0;i<n;i++) ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
e8711e91ab713a84cc2ca629d77e2d6c
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); int[] a=new int[n]; int sum=0,i,max=a[0]; for(i=0;i<n;i++) a[i]=s.nextInt(); for(i=0;i<n;i++) if(max<a[i]) max=a[i]; for(i=0;i<n;i++) { ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
fd3522789c7f17de00d8643603244ad5
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; public class HolidayOfEquality { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int all[] = new int[n]; int sum = 0; for(int i = 0 ; i<n; i++) { all[i]=sc.nextInt(); } Arrays.sort(all); //�Ѥp��j // System.out.println(all[0]); ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
55369a963307f9e5ead9679d4987b5bc
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; public class HolidayOfEquality { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int all[]= new int[n]; int sum = 0; int max = -1; for(int i =0 ; i<n; i++) { int input = sc.nextInt(); if(input>max) { max = input; } s...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
2006f405fa9c88f3aec444bde2eb89a0
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int n = cin.nextInt(); int[] a =new int[105]; int ans=0,aim=0; for(int i=0;i<n;i++){ a[i]=cin.nextInt(); if(aim<a[i]) aim=a[i]; } for(int i=0;i<n;i++){ ans+=aim-a[i]; } Sy...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
bbc3ccc7ecca324d0f608b153f8845b9
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; public class prob{ public static void main(String args[]){ Scanner in =new Scanner(System.in); int n=in.nextInt(); int a[]=new int[n]; int max=-1; for(int k=0;k<n;k++){ a[k]=in.nextInt(); if(a[k]>max) max=a[k]; } int count=0; for(int k=0;k<n;k++){ count+=max-a[k]; } System.out.printl...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
6b6a37b3d7c87a4d04b150285c4ee8e9
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { // Your code here! BufferedReader ac = new BufferedReader(new InputStreamReader(System.in)); String b = ac.readLine(); int len = Integer.parseInt(b); String c...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
0209d97d7a71f359d51e4dd1eba91522
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); in...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
bae94526984e68ac344ad55e6964c322
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; public class Train { public static void main(String[] args) { Scanner kb = new Scanner(System.in); int n= kb.nextInt(); int[] nm = new int[n]; for(int i=0;i<n;++i){ int l=kb.nextInt(); nm[i]=l; } Arrays.sort(nm); ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
3b9da86d9dccdbcdbc919066cde9ac00
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class abcd { public static void main(String[] arg){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] inp = new int[N]; for (int i = 0;i<N;i++){ inp[i] = sc.nextInt(); } int m = max(inp); int s = 0; for (int i = 0;i<N;i++)...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
0fdd04691d75ea2ec874615ea4b09e39
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Objects; import java.util.Scanner; public class HelloWorld { public static void main(String[] args) { Scanner in = new Scanner (System.in); int n= in.nextInt(),k=0,m=0; int [] money=new int [n]; for (int i =0;i<n;i++) { Scanner in2 = new Scanner (System.in); money [i]= in...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
2fc18ec4d4edbc8ca5a6495fcb67b690
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; public class holidayOfEquality { public static void main(String args[]){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int arr[]=new int[n]; for(int i=0;i<n;i++){ arr[i]=sc.nextInt(); } if(arr.length==1){ System.out.println("0"); } else { int max=arr[0]; ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
46e1ed7b6023a8b67bca67d262edd0c8
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.PrintWriter; import java.util.Arrays; import j...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
9e0f72792736d60369f919ca70d3a72a
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.io.PrintWriter; import static java.lang.System.out; import java.util.Random; import java.util.Scanner; import java.util.Arrays; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; im...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
4d289b90ec6915f5cf82ce7fd665a5b2
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Scanner; public class HolidayOfEquality { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[n]; int max=0; int total=0; for(int i=0; i<n; i++){ a[i]=sc.nextInt(); ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
64b97a2399699114eaf5f57e2fdfae74
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Scanner; public class Class1{ public static void main(String[] args){ int n; Scanner in= new Scanner(System.in); n =in.nextInt(); int[] a = new int[1000000]; int i; for(i=0;i<n;i++) a[i]=in.nextInt(); int l=a[0]; for(i=0;...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
d3406623afca059ead116155bd49d4e4
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; public class main1 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int no = in.nextInt(); int[] arr = new int[no]; int max = 0, counter = 0; for (int i = 0; i < no; i++) { arr[i] = in.nextInt(); if (arr...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
5918ca7fb7eaa62f4edca36cd74df7bc
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int no=in.nextInt(); int arr[]=new int[no]; for(int i=0;i<no;i++) ar...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
9bd1697cd31d52f0f76d4d2acd732121
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
/* * File: Breakout.java * ------------------- * Name: * Section Leader: * * This file will eventually implement the game of Breakout. */ import java.applet.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import java.util.HashMap; import java.util.Scanner; import java.util.StringT...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
fd6b90816d23df267d58ecc3bb1d888e
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
8040a1e5a9fbab8faf09cf88e8fdf1e9
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; import java.io.*; public class burles { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] arr = new int[n]; int maxx = Integer.MIN_VALUE; int i; for(i=0;i<n;i++) { arr[i] = in.nextInt(); maxx = Math.max(maxx, arr[i]); ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
dc0a838d55fe54f8dd27128fc4ddd326
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.*; import java.io.*; public class burles { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] arr = new int[n]; int maxx = Integer.MIN_VALUE; for(int i=0;i<n;i++) { arr[i] = in.nextInt(); maxx = Math.max(maxx, arr[i]); ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
04f45baf61ef29d0e43cf764b3fc6615
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Scanner; public class BMain{ public static void main(String[] args){ Scanner s = new Scanner(System.in); int count = s.nextInt(); int max = s.nextInt(); int sum = max; for (int i =0 ;i< count-1 ;i++){ int n = s.nextInt(); sum += n; ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
7a6733d9f2576d681a03acfc155af0fe
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input= new Scanner(System.in); int n = input.nextInt(); int a[]= new int[n]; int max=-1; for(int i=0;i<n;i++){ a[i]=input.nextInt(); max=Math.max(max, a[i]); } int ...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
24211ebf27905fe4b9486826ef8f6471
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int arr[]=new int[n]; for(int i=0;i<n;i++) { arr[i]=input.nextInt(); } int max=arr[0]; int min=arr[0]; int sum=0; for(int i...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
44ff2d6daa9da3d4e6b867a4029510dc
train_002.jsonl
1484838300
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).You...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Codeforces392a { public static void main(String[] args) { Scanner in = new Scanner(System.in); int people = in.nextInt(); int ar[] = new int[people]; for(int i=0; people>i;i++){ ar[i]=in.nextInt(); } Arrays.sort(ar); int sum=0; for(in...
Java
["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12"]
1 second
["10", "1", "4", "0"]
NoteIn the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.In the second example it is enough to give one burle to the third citizen. In the third example it is necessary to give two burles to the first and the thi...
Java 8
standard input
[ "implementation", "math" ]
a5d3c9ea1c9affb0359d81dae4ecd7c8
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom. The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
800
In the only line print the integer S — the minimum number of burles which are had to spend.
standard output
PASSED
4f63cd1f3a88f889f3879a634e4f0ef4
train_002.jsonl
1350370800
There are two decks of cards lying on the table in front of you, some cards in these decks lay face up, some of them lay face down. You want to merge them into one deck in which each card is face down. You're going to do it in two stages.The first stage is to merge the two decks in such a way that the relative order of...
256 megabytes
import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.Scanner; public class H { public static ArrayList<Integer> solve(int[] ar) { ArrayList<Integer> res = new ArrayList<Integer>(); for (int i = 0; i < ar.length; i++) { ...
Java
["3\n1 0 1\n4\n1 1 1 1", "5\n1 1 1 1 1\n5\n0 1 0 1 0"]
2 seconds
["1 4 5 6 7 2 3\n3\n5 6 7", "6 1 2 3 4 5 7 8 9 10\n4\n1 7 8 9"]
null
Java 7
input.txt
[ "constructive algorithms", "greedy" ]
f1a312a21d600cf9cfff4afeca9097dc
The first input line contains a single integer n — the number of cards in the first deck (1 ≤ n ≤ 105). The second input line contains n integers, separated by single spaces a1, a2, ..., an (0 ≤ ai ≤ 1). Value ai equals 0, if the i-th card is lying face down, and 1, if the card is lying face up. The cards are given in ...
2,000
In the first line print n + m space-separated integers — the numbers of the cards in the order, in which they will lie after the first stage. List the cards from top to bottom. The cards from the first deck should match their indexes from 1 to n in the order from top to bottom. The cards from the second deck should mat...
output.txt
PASSED
54ae7fe4c68732fafb1824541a0c7a17
train_002.jsonl
1350370800
There are two decks of cards lying on the table in front of you, some cards in these decks lay face up, some of them lay face down. You want to merge them into one deck in which each card is face down. You're going to do it in two stages.The first stage is to merge the two decks in such a way that the relative order of...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class H implements Runnable { private InputReader in; private PrintWriter out; public static void main(String[] args) { new H().run(); } public H() { //in = new InputReader(System.in); out = new PrintWriter(System.out); try {in =...
Java
["3\n1 0 1\n4\n1 1 1 1", "5\n1 1 1 1 1\n5\n0 1 0 1 0"]
2 seconds
["1 4 5 6 7 2 3\n3\n5 6 7", "6 1 2 3 4 5 7 8 9 10\n4\n1 7 8 9"]
null
Java 7
input.txt
[ "constructive algorithms", "greedy" ]
f1a312a21d600cf9cfff4afeca9097dc
The first input line contains a single integer n — the number of cards in the first deck (1 ≤ n ≤ 105). The second input line contains n integers, separated by single spaces a1, a2, ..., an (0 ≤ ai ≤ 1). Value ai equals 0, if the i-th card is lying face down, and 1, if the card is lying face up. The cards are given in ...
2,000
In the first line print n + m space-separated integers — the numbers of the cards in the order, in which they will lie after the first stage. List the cards from top to bottom. The cards from the first deck should match their indexes from 1 to n in the order from top to bottom. The cards from the second deck should mat...
output.txt
PASSED
a73efa1b27810bebf792e4095db9cb1e
train_002.jsonl
1350370800
There are two decks of cards lying on the table in front of you, some cards in these decks lay face up, some of them lay face down. You want to merge them into one deck in which each card is face down. You're going to do it in two stages.The first stage is to merge the two decks in such a way that the relative order of...
256 megabytes
import java.io.*; import java.util.*; public class P234H { public static StringTokenizer st; public static void nextLine(BufferedReader br) throws IOException { st = new StringTokenizer(br.readLine()); } public static String next() { return st.nextToken(); } pu...
Java
["3\n1 0 1\n4\n1 1 1 1", "5\n1 1 1 1 1\n5\n0 1 0 1 0"]
2 seconds
["1 4 5 6 7 2 3\n3\n5 6 7", "6 1 2 3 4 5 7 8 9 10\n4\n1 7 8 9"]
null
Java 7
input.txt
[ "constructive algorithms", "greedy" ]
f1a312a21d600cf9cfff4afeca9097dc
The first input line contains a single integer n — the number of cards in the first deck (1 ≤ n ≤ 105). The second input line contains n integers, separated by single spaces a1, a2, ..., an (0 ≤ ai ≤ 1). Value ai equals 0, if the i-th card is lying face down, and 1, if the card is lying face up. The cards are given in ...
2,000
In the first line print n + m space-separated integers — the numbers of the cards in the order, in which they will lie after the first stage. List the cards from top to bottom. The cards from the first deck should match their indexes from 1 to n in the order from top to bottom. The cards from the second deck should mat...
output.txt
PASSED
be44fc5deeea135943b08b9dbf9019fa
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.lang.reflect.*; import java.util.*; public class C { public C () { int N = sc.nextInt(); int M = sc.nextInt(); Integer [][] G = new Integer [N][3]; int [] D = new int[N]; for (@SuppressWarnings("unused") int i : rep(M)) { int x = sc.nextInt() - 1, y = sc.nextInt() - 1; ...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
f4fc428030faac626c16b1c5bfcfdb6a
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.lang.reflect.*; import java.util.*; public class C { final int MOD = (int)1e9 + 7; final double eps = 1e-12; final int INF = (int)1e9; public C () { int N = sc.nextInt(); int M = sc.nextInt(); Integer [][] E = new Integer [N][3]; int [] NE = new int[N]; for (int i = 0; ...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
63a0da323e08d8ee94db0dfed33b9829
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.lang.reflect.*; import java.util.*; public class C { final int MOD = (int)1e9 + 7; final double eps = 1e-12; final int INF = (int)1e9; public C () { int N = sc.nextInt(); int M = sc.nextInt(); Integer [][] E = new Integer [N][3]; int [] NE = new int[N]; for (int i = 0; ...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
ffd0c8da1798fa9c542122c863f21798
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.lang.reflect.*; import java.util.*; public class C { final int MOD = (int)1e9 + 7; final double eps = 1e-12; final int INF = (int)1e9; public C () { int N = sc.nextInt(); int M = sc.nextInt(); Integer [][] E = new Integer [N][3]; int [] NE = new int[N]; for (int i = 0; ...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
24734e41289b76b582acf2630010f756
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.lang.reflect.*; import java.util.*; public class C { public C () { int N = sc.nextInt(); int M = sc.nextInt(); Integer [][] G = new Integer [N][3]; int [] D = new int[N]; for (@SuppressWarnings("unused") int i : rep(M)) { int x = sc.nextInt() - 1, y = sc.nextInt() - 1; ...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
60e87a1fe90f2065bbf75cfbf7736342
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.lang.reflect.*; import java.util.*; public class C { final int MOD = (int)1e9 + 7; final double eps = 1e-12; final int INF = (int)1e9; public C () { int N = sc.nextInt(); int M = sc.nextInt(); Integer [][] E = new Integer [N][3]; int [] NE = new int[N]; for (int i = 0; i...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
0c28237d627e95484d671f83c8f8e70a
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.lang.reflect.*; import java.util.*; public class C { public C () { int N = sc.nextInt(); int M = sc.nextInt(); Integer [][] G = new Integer [N][3]; int [] D = new int[N]; for (@SuppressWarnings("unused") int i : rep(M)) { int x = sc.nextInt() - 1, y = sc.nextInt() - 1; ...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
13d31327102fb1da6021772cb41031ca
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.util.*; public class Solver { int n; Vector<Integer>[] g; int[] clr; boolean isBad(int num) { int cnt = 0; for (int i = 0; i < g[num].size(); i++) { int v = g[num].elementAt(i); if (clr[v] == clr[num]) cnt++; } return cnt > 1; } void solve() throws IOExce...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
5e2a1d0ff840b66ac98f4801d96927c7
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.util.*; public class Solver { int n; Vector<Integer>[] g; int[] clr; StringTokenizer st = new StringTokenizer(""); BufferedReader in; PrintWriter out; String nextToken() throws IOException { while (!st.hasMoreTokens()) st = new StringTokenizer(in.readLine()); return st.nextTo...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
f9b0f2c309341906c8a75788fcc79f95
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.util.*; public class Solver { int n; Vector<Integer>[] g; int[] clr; boolean isBad(int num) { int cnt = 0; for (int i = 0; i < g[num].size(); i++) { int v = g[num].elementAt(i); if (clr[v] == clr[num]) cnt++; } return cnt > 1; } void solve() throws IOExce...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
9b5c9d8c7705748f5be411f3baf0127c
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { int n, m; int g[][]; int [] whites, blacks, color; void paint (int v, int c) { for (int i = 0; i < g[v].length; i++) { int to = g[v][i]; if (col...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
cfe326bac5a4bc60988ca22a9dccbb4b
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import static java.lang.Math.*; import java.util.*; import static java.util.Arrays.fill; import static java.util.Arrays.sort; public class Main { public static void main(String[] args) { if(new File("input.txt").exists()) try { System.setIn(new FileInputStream("input.txt")); } catch (Fi...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
e3eb7aafb1682663ec9f0eaa64bf534a
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class C { ArrayList<Integer>[] arr; int[] col; void dfs(int v, int num) { if (col[v] != 0) { return; } col[v] = num; for (int k = 0; k < arr[v].size(); k++) { int to = arr[v].get(k); dfs(to, 3 - num); } } void coun...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
227d080d7e460262e5498e89cc1dda01
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.ArrayList; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author ...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
a36247c8437178765c2d8c8b7ca861c1
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.OutputStream; import java.util.ArrayDeque; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import java.util.Queue; impor...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
e3e23087adc1befc6a7354f946231bff
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.util.ArrayList; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import java.util.StringTokenizer; im...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
2d034d87406e5f1672e9e2290ee51e71
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.PriorityQueue; import java.util.StringTokenizer; public class M { boolean res[...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
b88a5f8e7eacced164cd91da7a53aec1
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.util.*; public class C implements Runnable { public static void main(String[] args) { new Thread(new C()).run(); } BufferedReader br; StringTokenizer in; PrintWriter out; public String nextToken() throws IOException { while (in == null || !in.hasMoreTokens()) { in = new Str...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
b06f0e97fb2f3fddbd91f63a7123333f
train_002.jsonl
1360769400
Dima came to the horse land. There are n horses living in the land. Each horse in the horse land has several enemies (enmity is a symmetric relationship). The horse land isn't very hostile, so the number of enemies of each horse is at most 3.Right now the horse land is going through an election campaign. So the horses ...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class Main { InputReader reader; PrintWriter writer; Main() { reader = new InputReader(); writer = new PrintWriter(System.out); } public static void main(String[] args) { new Main().run(); } public ...
Java
["3 3\n1 2\n3 2\n3 1", "2 1\n2 1", "10 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4"]
2 seconds
["100", "00", "0110000000"]
null
Java 7
standard input
[ "greedy", "graphs" ]
7017f2c81d5aed716b90e46480f96582
The first line contains two integers n, m — the number of horses in the horse land and the number of enemy pairs. Next m lines define the enemy pairs. The i-th line contains integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi), which mean that horse ai is the enemy of horse bi. Consider the horses indexed in some way from 1 to n...
2,200
Print a line, consisting of n characters: the i-th character of the line must equal "0", if the horse number i needs to go to the first party, otherwise this character should equal "1". If there isn't a way to divide the horses as required, print -1.
standard output
PASSED
24ccea37acc1f7e0624f10ba48e92283
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.io.FileInputStream; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Main { private static boolean local = false; public static void main(String[] args) throws Exception { ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
4d2baf94460bb87ea6d364d85eb75c10
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Mouna Cheikhna */ public class Main { public static void main(String[] args) { InputS...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
a6ed8ca2d23302b5b8b64c6774e3c293
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; /** * * @author Saju * */ public class Main { private static int dx[] = { 1, 0, -1, 0 }; private static int dy[] = { 0, -1, 0, 1 }; private static final long INF = Long.MAX_VALUE; private static final int INT_INF = Integer.MAX_VALUE; ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
099edc22b31735e651716c7aaa15dba3
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.io.*; import java.util.*; public class CF { FastScanner in; PrintWriter out; void solve() { int n = in.nextInt(); int m = in.nextInt(); char[][] a = new char[n][]; for (int i = 0; i < n; i++) { a[i] = in.next().toCharArray(); } ArrayList<Integer> from = new ArrayList<>(); ArrayList<Int...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
9270c9c8bbd9fdc092ea7fbd5b421db9
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public class Codeforces { static double Phi = (1 + Math.sqrt(5)) / 2.0; static int MAX = -1 >>> 1; static long MODL = 1_000_000_007L; static int MOD = 1_000_000_007; static void no() {println("NO");} static void yes(...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
12fce31e36b09e89a2c719632dd007eb
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author fintech */ public class Main { public static void main(String[] args...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
2f4d8b3c6a96fc7b0c6127f2f55d711f
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main { static BufferedReader reader; static StringTokenizer tokenizer; static PrintWriter writer;...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
c2712ea4c79e8822852916530627c932
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
// practice with rainboy import java.io.*; import java.util.*; public class CF497A extends PrintWriter { CF497A() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF497A o = new CF497A(); o.main(); o.flush(); } void main() { int n = sc.nextInt(); int m...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
073ec3555e971474f0eeac22b2e78487
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class Template { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
9865cb272a4718dec5222edf3fb49ba6
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Task task = new Task(); System.out.println(task.solve()); } } class Task { private int n, m; boolean [][] correct = new boolean[105][105] ; boolean [] deleted = new boolean [105] ; ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
a0672af116179e9012fb446508b1ac16
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.util.*; import java.io.*; public class A { public static long time = 0; public static void main(String[] args) throws Exception { time = System.currentTimeMillis(); IN = System.in; OUT = System.out; in = new BufferedReader(new InputStreamReader(IN)); ...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
fc0181ceca2d26d8ecf7e219460554ee
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
37ce76005df007d46eb71d0ed27f01ec
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
11d2bd0fb42d11812eff0f572025507d
train_002.jsonl
1418833800
You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class RemovingColumns { public static void main(String args[] ) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter w = ne...
Java
["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces"]
2 seconds
["0", "2", "4"]
NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larg...
Java 8
standard input
[ "greedy" ]
a45cfc2855f82f162133930d9834a9f0
The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.
1,500
Print a single number — the minimum number of columns that you need to remove in order to make the table good.
standard output
PASSED
5ba8e006299575f81bd5c74364ce4d5b
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ public static class pair{ int x; int y; } public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine())...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
052cfec6a85aa8fe3f38fa5f75be1308
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
/* package codechef; // don't place package name! */ import java.util.*; import java.io.*; import java.math.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws IOException { Reader s=new Reader(); BufferedReader br=new...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
106c87b10cbbfae3ce180a165f0086e5
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(in.readLine()); for(int t = 0; t < T; t++){ int n = Integer.parse...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output
PASSED
5d52130907f02847a4c76ba40b9b3e48
train_002.jsonl
1581604500
Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elem...
256 megabytes
import java.util.*; import java.util.Arrays; public class solve { public static void main(String args[]) { Scanner in=new Scanner(System.in); int t=in.nextInt(); while(t!=0) { t--; int n=in.nextInt(); int m=n; int a[]=new int[n]; ...
Java
["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5"]
2 seconds
["1 11\n5 35\n3 6\n0 42\n0 0\n1 2\n3 4"]
NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$...
Java 8
standard input
[ "binary search", "greedy", "ternary search" ]
8ffd80167fc4396788b745b53068c9d3
The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The s...
1,500
Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacin...
standard output