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 | 3f2146fd20b6316033e47a8ffb13f72f | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arra... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | cbb67b2d3ffedf7870b88eec9bfca247 | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.util.Scanner;
public class ProblemB {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int klein = 0, gleich = 0, gross = 0;
for (int i = 0; i < N; i++) {
int x = sc.nextInt();
if (x < M) klein++;
else if (x > ... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | b81fc8f98c6e0b6033c0b37aed226dbd | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class Median {
public static void main(String[] args) throws Exception {
Scanner input = new Scanner(System.in);
// 0 1 2 3 4 5 6 7
// 6 => 6 - (items - 6) + (newMedLoc > currentMedLoc ? 1 : 0)
// 2 4 6 8 1... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | fbe094585785f8c81f5fd61c24cb2266 | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
public static void main(String[] argv) {
new Main().run();
}
void run() {
in = new Scanner(System.in);
out = new PrintWriter(System.out);
try {
solve();
} finally {
... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | 3899c78d86db78a2d9ea4a8b87cc2bea | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.util.*;
public class Median {
public static void main(String[] args){
Scanner key=new Scanner(System.in);
int len = key.nextInt();
// if(median%2==1)median++;
int tgtNum=key.nextInt();
key.nextLine();
int index=0;
int [] vals = new int[len];
f... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | 0399f081e363a7e5341367ebbcd37517 | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
public class Main {
private void solve() {
int n = in.nextInt();
int x = in.nextInt();
Vector<Integer> v = new Vector<>();
for(int i =0 ; i < n; ... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | 75bd39fcdb89f2ef3b6012795430dfa6 | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.util.*;
import java.math.*;
import java.io.*;
public class Main {
public static StringTokenizer st;
public static BufferedReader scan;
public static PrintWriter out;
public static void main(String[] args) throws IOException{
scan = new BufferedReader(new InputStreamReader(System.in)... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | e1373f0cdfa77ef27bec5ea8cfe9fe3d | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.io.*;
import java.util.*;
public class middle implements Runnable {
public StringTokenizer strtok;
public BufferedReader inr;
public PrintWriter out;
public static void main(String[] args) {
new Thread(new middle()).start();
}
public static final String taskname = "middle";
public void run() {
... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | 7f9003fe59cff70d1218c4cf41e2587b | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.TreeSet;
public class C {
static StreamTokenizer st;... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | 0fc30359838e61504e856d0528909cd3 | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.io.*;
import java.util.*;
public class j
{
public static void main(String aa[])throws IOException
{
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
int x=0,i=0,p=0,tr=-1,tl=-1,n=0,k=0;
String s;
s=b.readLine();
StringTokenizer c=new StringTokenizer(s);
n=Integer.parseInt(c.nextToken()... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | 6aa59c06b02aea89ad3baec17b8fa183 | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
/*
11 3
1 2 2 2 2 2 3 3 3 3 3
13 1
1 1 1 1 2 2 3 3 3 3 3 3 3
13 2
1 1 1 1 2 2 3 3 3 3 3 3 3
12 3
1 1 1 1 2 2 3 3 3 3 3 3
7 3
2 2 4 4 5 6 7
7 8
2 2 4 4 5 6 7
*/
public class Main {
public static Scanner scan = new Scanner(System.in);
public static bool... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | bbe4f22c16e245423e44d4a0b339b75b | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main implements Runnable {
public void solve() throws IOException {
int N = nextInt();
int median = nextInt();
int[] a = new int[N];
for(int i = 0; i < N; i++) a[i] = nextInt();
Arr... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | 46ff864aeaae13192bb49010683c90d2 | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.util.*;
public class Median{
public static void main(String[] Args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int b = 0;
int a = 0;
for(int k =0;k<n;k++){
int t = sc.nextInt();
if(t<m)
a++;
... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | 9e07d37643d7a5fce75d714d64c49234 | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
public class Solution {
long ... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | 381c4e6b7d2c032850d12a850427240d | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Task166C {
public static void main(String... args) throws NumberFormatException,
IOException {
Solutio... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | 20495e051354013651175063fc3195d1 | train_000.jsonl | 1332516600 | A median in an array with the length of n is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,β6,β1,β2,β3) is the number 2, and a median of array (0,β96,β17,β23) β the number 17.We define an expre... | 256 megabytes | import java.util.Comparator;
import java.util.Scanner;
import java.util.TreeSet;
public class c {
static class Pair {
int val;
int uniq;
Pair(int val, int uniq) {
this.val = val;
this.uniq = uniq;
}
@Override
public String toString() {
return val + " " + uniq;
}
}
static int unique = 1;
... | Java | ["3 10\n10 20 30", "3 4\n1 2 3"] | 2 seconds | ["1", "4"] | NoteIn the first sample we can add number 9 to array (10,β20,β30). The resulting array (9,β10,β20,β30) will have a median in position , that is, 10.In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4. | Java 7 | standard input | [
"sortings",
"greedy",
"math"
] | 1a73bda2b9c2038d6ddf39918b90da61 | The first input line contains two space-separated integers n and x (1ββ€βnββ€β500, 1ββ€βxββ€β105) β the initial array's length and the required median's value. The second line contains n space-separated numbers β the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily... | 1,500 | Print the only integer β the minimum number of elements Petya needs to add to the array so that its median equals x. | standard output | |
PASSED | 9e1913f96e71d4d6422c83fc6b31ca6f | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
public class Solution {
public static void main(String[] args) throws IOException {
IO io = new IO() ;
int n = io.getInt(), cur = 1 ;
List<Integer> l = io.getIntegerArray(n) ;
l.sort(Comparator.comparingInt(... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 48f19b3604cd920c1f13dfea037e4aa3 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.Inpu... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | afc568f90b2e6fd9ccc896da7972b605 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.util.PriorityQueue;
import java.util.Scanner;
public class CF358B {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt(), curr = 0;
PriorityQueue<Integer> a = new PriorityQueue<Integer>();
for(int i = 0; i < n; i++)a.add(scan.nextInt());
for(int... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 2fc00f66358311d6992a7a82b6c386d4 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes |
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Alyona_and_Mex1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
//long[] arr = new long[(int) n];
ArrayList <Long> arr = ne... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 061148a2837c659debd6b86e533e1692 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;
public class alyonaMex682B {
public static void main (String[] args) throws Exception {
... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 19a5420f568f59aae05ddaec8e82391a | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.util.*;
public class B682 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int m = 100001;
int[] ar = new int[m];
for (int i = 0; i < n; i++) {
int cur = scan.nextInt();
ar[Math.min(cur, 100000)]++;
}
int max = 0;
for... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | af29a79b9eeb19500c59780ad8eb1ca2 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class R358B {
public static void main (String[] args) throws java.lang.Exception {
InputReader in = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
int n = in.nextInt();
Long[] a = new Long[n... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 834c820b390f724d0a85fb2d5c000b7a | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes |
import java.util.*;
import java.lang.*;
import java.io.*;
public class R358B {
public static void main (String[] args) throws java.lang.Exception {
InputReader in = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
int n = in.nextInt();
ArrayList<Long> a = ... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | f45926e3275978f00dc118a1a962c9b5 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes |
/**
* Created by bubbl on 6/27/2016.
*/
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception{
FastScanner sc = new FastScanner();
int n = sc.n... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 11485bbe50b97bdb562e5fc4c0375af0 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.util.*;
import java.io.*;
/**
* @author Mighty Cohadar
*/
public class Bravo {
static void insertionSort(int[] A, int li, int re) {
for (int r = li + 1; r < re; r++) {
int val = A[r];
int l = r;
while (li < l && A[l-1] > val) {
A[l] = A[l-1];
l--;
}
A[l] = val;
}
}
sta... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 2584c71b70e01c305ca3b698d7748a18 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.util.*;
import java.io.*;
/**
* @author Mighty Cohadar
*/
public class Bravo {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.valueOf(br.readLine());
List<Integer> L = new ArrayList<>();
Stri... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 2502b8ed7c953f94e6ce333443914e67 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.util.*;
import java.io.*;
/* Mighty Cohadar */
public class Bravo {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
PriorityQueue<Integer> Q = new PriorityQueue<>();
for (int i = 0; i < n; i++) {
Q.add(scanner.nextInt());
}
int ... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | aa54b849db371bf8499f7097e95f87a7 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.util.*;
import java.io.*;
/* Mighty Cohadar */
public class Bravo {
public static void main(String[] args) {
FastScanner scanner = new FastScanner(System.in);
int n = scanner.nextInt();
PriorityQueue<Integer> Q = new PriorityQueue<>();
for (int i = 0; i < n; i++) {
Q.add(scanner.nextInt());
... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 03e01f188582c3d0071ddb4ec87cb25b | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes |
import java.util.*;
import java.io.*;
import java.util.Scanner;
/**
* Created by Hp on 6/18/2016.
*/
public class B {
public static void main(String [] ar) throws IOException{
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(buffere... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 4aad4047aa1b931f79edef9aa5f5a502 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
public class B {
int N;
Integer[] a;
public void solve() {
N = nextInt();
a = new Integer[N];
for(int i = 0;i < N;i++){
a[i] = new Integer(nextInt());
}
... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 7bfaca24e8f412fd28026a71fab15da5 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.NoSuchElementException;
public class B {
int N;
ArrayList<Integer> a,b;
public void solve() {
N = nextInt();
a = new ArrayList<Integer>();
b = new Arr... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | b909af791c68333d8e2b4b2ad21abdca | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;
public class B {
int N;
int[] a;
public void shuffleArray(int[] arr) {
int n = arr.length;
Random rnd = new Random();
for (int i = 0;... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | af319b011a4280a3ca76081f35cf49f4 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;
/**
* Created by Shurikat on 09.07.16.
*/
public class Codeforces {
static Integer[] array;
static Integer[] t;
public static void main(String[] args) th... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 80dc21ed1f76001c66120d5751636e01 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;
/**
* Created by Shurikat on 09.07.16.
*/
public class Codeforces {
static Integer[] array;
public static void main(String[] args) throws Exception {
... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 76c1674a7a4f92e1af520ea6f9a179d7 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
/**
* Created by Shurikat on 09.07.16.
*/
public class Codeforces {
static int[] array;
private static void doSort(int start, int end) {
if (start >... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 372e8c5ce9bbd16cc18ff150d88f0800 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;
/**
* Created by Shurikat on 09.07.16.
*/
public class Codeforces {
static Integer[] array;
public static void main(String[] args) throws Exception {
... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 53f3613261ab7942371bc04c8dfaa880 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;
/**
* Created by Shurikat on 09.07.16.
*/
public class Codeforces {
static Integer[] t;
public static void main(String[] args) throws Exception {
Buf... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | d4ff689c5edbd6c0d97e3773bfc92a24 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
/**
* Created by Shurikat on 09.07.16.
*/
public class Codeforces {
static Integer[] array;
// private static void doSort(int start, int end) {
// if (start >= end)
// return;
// int i = start, j = en... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | f016e9ca490a6e9d57414860cedf7277 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.util.concurrent.*;
public class Main {
//---------------------------------------------------------------------------
public static void main(String[] args) throws Exception {
InputReader in = new InputReader(Syst... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | c0def57ee0bb195bb468296b937bcfad | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
public class Main {
//---------------------------------------------------------------------------
public static void main(String[] args) throws Exception {
InputReader in = new InputReader(System.in);
PrintWriter out... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | b6c26b8c3856666b3bcb286c555cd98c | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Locale;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
public class Main {
public static void main(S... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 77d71c5366e57237ee3b00d1c09b457a | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main{
public static PrintWriter out;
public static class MyScanner {
... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 3cab1193f61e403eecaacc78afc71dd4 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
public class Main {
public static void main(String[] a... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 11340df94f73d7715c183a382df35d37 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
public class Main {
public static void main(String[] a... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 7d977d0f508e6d79ba0f581ba318aa16 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
public class Main {
public static void main(String[] a... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 66a80a7d2667b1ef7ff710395dda312d | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
public class Main {
public static void main(String[] a... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | f4319624227dcf4dee26116701675609 | train_000.jsonl | 1466181300 | Someone gave Alyona an array containing n positive integers a1,βa2,β...,βan. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not ... | 256 megabytes | import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
public class Main {
public static void main(String[] a... | Java | ["5\n1 3 3 3 6", "2\n2 1"] | 1 second | ["5", "3"] | NoteIn the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.To reach the answer to the second sample case one must not decrease any of the array elements. | Java 8 | standard input | [
"sortings"
] | 482b3ebbbadd583301f047181c988114 | The first line of the input contains a single integer n (1ββ€βnββ€β100β000)Β β the number of elements in the Alyona's array. The second line of the input contains n integers a1,βa2,β...,βan (1ββ€βaiββ€β109)Β β the elements of the array. | 1,200 | Print one positive integerΒ β the maximum possible value of mex of the array after Alyona applies some (possibly none) operations. | standard output | |
PASSED | 3b3c9285aa8a6a6edaead3cc7cc07cbe | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | /*
* Remember a 6.0 student can know more than a 10.0 student.
* Grades don't determine intelligence, they test obedience.
* I Never Give Up.
* I will become Candidate Master.
* I will defeat Saurabh Anand.
* Skills are Cheap,Passion is Priceless.
*/
import java.util.*;
import java.util.Map.Entry;
import java.i... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 0cdcd60f14c05b4253708c83489ed2e8 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.*;
import java.util.*;
public class AlyonaTree {
static Graph g[];
static String ver[];
static int par[],count;
static long d[];
static boolean vis[];
public static void main(String args[]) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n=Intege... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | b68042d0aec8dc150c8084a904150763 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.awt.*;
import java.io.*;
import java.util.*;
public class Abc {
static int n;
static int arr[];
static int cnt[];
static ArrayList<Integer> adj[];
static Map<Point,Integer> map;
static int ans=0;
public static void main(String[] args) throws Exception {
FastReader sc = n... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 0f7cdde3c0f1d3aece06afb82907b44c | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class _Alyona_and_the_Trees {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parse... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 0410d3c3997c0887a941553b3d144961 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.BigInteger;
import java.util.regex.*;
public class Myclass {
public static ArrayList a[]=new ArrayList[200001];
static boolean visited[]=new boolean [200001];
static long value[];
static long maxi[];
static long dp[... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 18a904ed80621688b64ee558002c16ff | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class C358 implements Runnable{
static long oo = 987654321;
static long[] val;
static int[] mark;
... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | fb34945c4ad4db68b72d23e825309db1 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class C35... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 92d405d90280ad630129c0729e856243 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
import java.util.StringTokenizer;
public class Main ... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 95e61ee81289f9e7cfeac3a2ce4b1156 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;
public class Main {
void solve() {
int n = sc.nextInt();
V[] vs = new V[n];
for (int i = 0; i < n; i++) {
vs[i] = new V();
vs[i].id = i + 1;
}
for (int i = 0; i < n; i++) {
vs[i].a = sc.next... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 1a4b1fd2c5054f8b17b7134d7de3dd8d | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.Writer;
impo... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | d65d193b52b543de5886fb3b99dbecb5 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.util.Scanner;
import java.util.HashMap;
public class Tester {
static Node[] node;
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
node = new Node[n];
for(int i=0;i<n;i++){
node[i] = new Node(scan.ne... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | fbb2e58776c7ca0246028b395725b788 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 07c4d19706bbd789dd85d372dbd88c86 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.util.*;
import java.io.*;
//import java.lang.*;
public class ranjan{
public static Read cin;
public static PrintWriter cout;
public static boolean[] visited;
public static final long b = (long)1e9+7;
public static int fileread = 0;
public static void main(String ...arg) thro... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 3438f0d74d1da6aa0d8eaed52c44ffc3 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.util.*;
import java.io.*;
//import java.lang.*;
public class ranjan{
//public static Read cin;
public static InputReader cin;
public static PrintWriter cout;
public static boolean[] visited;
public static final long b = (long)1e9+7;
public static int fileread = 0;
public... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 3d495006e38e64a5f917338b0f22b4c9 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.util.*;
import java.io.*;
public class gfg {
public static void main(String[] args) throws IOException{
//Reader.init(System.in);
//PrintWriter out = new PrintWriter(System.out);
Reader.init(System.in);
int t = 1;//Reader.nextInt();
while(t-->0){
... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 74262f747629e6ab512eb9881b63eacc | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.util.*;
import java.io.*;
public class pt{
static class Edge{
int s,d,w;
Edge(int S,int D,int W)
{ s=S ; d = D; w = W;}
}
static void dfs(LinkedList<Edge> l[],int s,int p,int sz[]){
... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 91380e14c0a4ec0eab107630f5de8106 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.util.ArrayList;
import java.util.Scanner;
public class WorkFile {
public static int[] dfs(long[] array, ArrayList<int[]>[] tree,
int item, int prev, long path, long minpath) {
int result = 0, amount = 1;
for (int[] elem:tree[item]) {
int x = elem[... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 8f01b544d87c777d5d7924813bfc4e74 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.io.*;
import java.math.*;
public class Main7
{
static class Pair
{
int x;
int y;
Pair(int x,int y)
{
this.x=x;
this.y=y;
}
}
static int mod=1000000007;
public static int[] sort(int[] a)
{
int ... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 884a12ae65a570206991a293db347a8b | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class dfs
{
static int n;
static LinkedList<Integer> adj[];
static HashMap<String, Integer> hm;
static int counter;
static int vis[];
static int arr[];
static int problem[];
static Set<Integer> hs;
public static void ... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 5e4c9c4a9598d322453cee5cf18d84a8 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.*;
import java.util.*;
public class C
{
public static long[] dp;
public static ArrayList<ArrayList<Edge>> g;
public static int cnt = 0;
public static void dfs(int u, int par, long minSoFar, long sumSoFar, boolean fail)
{
if(dp[u] < (sumSoFar - minSoFar) || fail == true) {
fail = true;
cnt++... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | b2ce63e5e3f5bfd4dbc0ceaa120e0407 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;
public class C {
static class N implements Comparable<N> {
int n;
int cost;
N(int i, int x) {
this.n = i;
this.cost = x;
}
@Override
public int compareTo(N o) {
return -Integer.compare(n, o.n);
}
}
... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | e0df690391dfe4c10ce87dceb9491de2 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | /*
* Code Author: Akshay Miterani
* DA-IICT
*/
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
static double eps=(double)1e-7;
static long mod=(int)1e9+7;
public static void main(String args[]){
InputReader in = new InputReader(System.in);
OutputStream outputStream = System.ou... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 9013d385639d0279545a1c30f4d5e66e | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.*;
import java.util.*;
public class C682
{
int id,wt;
static int cou[],arr[];static long dist[];static boolean vis[];
static HashSet<Integer> set=new HashSet<>();
static HashMap<Integer,ArrayList<C682>> map=new HashMap<>();
//static List<Integer> neg=new ArrayList<>();
publi... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 4171499b7b791f21e0570ace43614cf4 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class C extends cf {
public static void main(String[] args) {C c=new C();}
public void run(InputReader in, PrintWriter out) {
int n=in.nextInt(),ans=0,v,p,c,newd;
int[] a=new int[n+1],d=new int[n+1];
Li... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 60568b8dea180b91c1d5fd019b2f31c4 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class AlyonaandtheTree {
static int V;
static long val[];
static ArrayLis... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | a7be62de20cd18194e5530ca42fd3d19 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
/**
* Created by yujiahao on 9/14/16.
*/
public class cf_358_c {
private FastScanner in;
private PrintWriter out;
public void solve() ... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | c2a850e087a447de2a918e0325e18da8 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
/**
* Created by yujiahao on 9/14/16.
*/
public class cf_358_c {
private FastScanner in;
private PrintWriter out;
public void solve() ... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | c9691445bcceeb97f05549ab85bcf99b | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.util.*;
import java.math.*;
import java.io.*;
public class Luck{
public static InputReader sc;
public static PrintWriter out;
public static final long MOD = (long)1e9 + 7L;
static int n;
static ArrayList<Pair>[] adj;
static long[] A;
static long[] val;
static ArrayList<Integer> ... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 73fca7db117aff8b8a9c836281dfa025 | train_000.jsonl | 1466181300 | Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call verte... | 256 megabytes | import java.util.*;
import java.io.*;
public class R682C {
FastScanner in;
PrintWriter out;
long ans=1;
ArrayList<Pair>[] v;
boolean[] used;
long[]a;
void solve() {
int n=in.nextInt();
v = new ArrayList[n];
used = new boolean[n];
for(int i=0; i<n; i++) {
... | Java | ["9\n88 22 83 14 95 91 98 53 11\n3 24\n7 -8\n1 67\n1 64\n9 65\n5 12\n6 -80\n3 8"] | 1 second | ["5"] | NoteThe following image represents possible process of removing leaves from the tree: | Java 8 | standard input | [
"dp",
"dfs and similar",
"trees",
"graphs"
] | 0c4bc51e5be9cc642f62d2b3df2bddc4 | In the first line of the input integer n (1ββ€βnββ€β105) is givenΒ β the number of vertices in the tree. In the second line the sequence of n integers a1,βa2,β...,βan (1ββ€βaiββ€β109) is given, where ai is the number written on vertex i. The next nβ-β1 lines describe tree edges: ith of them consists of two integers pi and c... | 1,600 | Print the only integerΒ β the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. | standard output | |
PASSED | 8f9f413717965d2ae0692707ad864a82 | train_000.jsonl | 1339342200 | An oriented weighted forest is an acyclic weighted digraph in which from each vertex at most one edge goes.The root of vertex v of an oriented weighted forest is a vertex from which no edge goes and which can be reached from vertex v moving along the edges of the weighted oriented forest. We denote the root of vertex v... | 256 megabytes | // practice with kaiboy
import java.io.*;
import java.util.*;
public class CF195E extends PrintWriter {
CF195E() { super(System.out, true); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
CF195E o = new CF195E(); o.main(); o.flush();
}
static final int MD = 1000000007;
int[] pp, w... | Java | ["6\n0\n0\n1 2 1\n2 1 5 2 2\n1 1 2\n1 3 4", "5\n0\n1 1 5\n0\n0\n2 3 1 4 3"] | 2 seconds | ["30", "9"] | NoteConside the first sample: Vertex 1 is added. kβ=β0, thus no edges are added. Vertex 2 is added. kβ=β0, thus no edges are added. Vertex 3 is added. kβ=β1. v1β=β2, x1β=β1. Edge from vertex root(2)β=β2 to vertex 3 with weight depth(2)β+βx1β=β0β+β1β=β1 is added. Vertex 4 is added. kβ=β2. v1β=β1, x1β=β5. Edge from vert... | Java 11 | standard input | [
"data structures",
"dsu",
"graphs"
] | c4d464f1770d2c1b41f8123df4325615 | The first line contains a single integer n (1ββ€βnββ€β105) β the number of operations of adding a vertex. Next n lines contain descriptions of the operations, the i-th line contains the description of the operation of adding the i-th vertex in the following format: the first number of a line is an integer k (0ββ€βkββ€βiβ-β... | 2,000 | Print a single number β the sum of weights of all edges of the resulting graph modulo 1000000007 (109β+β7). | standard output | |
PASSED | 7201244b9b2195f295ebfea8b10b4a93 | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;
public class E {
public static void main(String[] args) throws Exception {
// StringTokenizer stok = new StringTokenizer(new Scanner(new Fil... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | 8d2dd66cb75818307fad43e454f647bb | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.io.*;
import java.util.*;
/*
ββββββββββββββββ β β βββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββ βββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
*/
public class Main {
static FastReader in;
sta... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | b457c20522bd3c44d20ff0a29999bbc0 | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import static java.lang.Math.*;
import java.util.stream.*;
public class E {
public Object solve () {
int N = sc.nextInt();
int [][] E = dec(sc.nextInts(N-1));
G = graph(N, E);
S = new int [2*N];
dfs(0, -1);
S[2*N-1] = -1;
int [][] res = new int [N][2]; int i = 1;
for (int s : S)
if (s > 0)
... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | d02df92c6df5a127c9ec94e1234df20a | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import static java.lang.Math.*;
import java.util.*;
import java.util.stream.*;
public class E {
public Object solve () {
int N = sc.nextInt();
int [][] E = dec(sc.nextInts(N-1));
G = graph(N, E);
dfs(0, -1);
S.add(-1);
int [][] res = new int [N][2]; int i = 1;
for (int s : S)
if (s > 0)
res[s... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | f1b261e7af5676f5d8e4eb17a20cc8ca | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import static java.lang.Math.*;
import java.util.*;
import java.util.stream.*;
public class E {
public Object solve () {
int N = sc.nextInt();
int [][] E = dec(sc.nextInts(N-1));
G = graph(N, E);
S = new int [2*N];
dfs(0, -1);
S[2*N-1] = -1;
int [][] res = new int [N][2]; int i = 1;
for (int s : S... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | a77b0bef0a5e5f22cd1ec56387e126fb | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main{
static PrintWriter out;
static InputReader in;
public static void main(String args[]){
out = new PrintWriter(System.out);
in = new InputReader();
new Main();
out.flush(); out.close();
}
Main(){
solve(... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | 009928e8dbec837b95d102bf445ef1ce | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
// written by luchy0120
public class Main {
public static void main(String[] args) throws Exception {
new Main().run();
}
int cnt=1;
int ps[][];
void dfs(int rt,int fa){
int sz =g[rt].size();
for(int i=... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | 91b7c552bc399f26ceb9225011fe5e09 | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class E {
static PrintWriter out = new PrintWriter(System.out);
static int[] l, r, sz;
static ArrayList<Integer> adj[];
static int N;
public static v... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | 8b102d1a2f7f7ae710b61cedc3396b67 | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | //package cf;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class USACO {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter (System.out);
... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | 9b180e462c315f4108c740579319333c | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | /*********** This template help me to solve the SLOW I/O ***********/
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class Main extends Thread {
public static int[] visit;
public static int max=1;
public static int[][] arr;
public static ArrayList<Integer>[] a... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | c7c028f901d528b921f359aabb9f84ae | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main{
public static class FastReader {
BufferedReader br;
StringTokenizer root;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (root == null || !root.hasM... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | f7444b24198915e4ade8a12bc0b28172 | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
public class ETask {
private static final String QUICK_ANSWER = "NO";
private final Input in;
private final StringBuilder out;
private int n;
int[] from;
int[] to;
private Tree tree;
public ETask(Input in, StringBuilder out) {
... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | ed6f5116856e843a78160646d4b102c1 | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.io.UncheckedIOException;
import java.util.List;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | 1422af99746d73ab3315621cc024d939 | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
static PrintWriter out;
static Reader in;
public static void main(String[] args) throws IOException {
//out = new PrintWriter(new File("out.txt"));
//PrintWriter out = new PrintWriter(System.out);
//in = ... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | 05141da056420846cad09ff35f6a7d92 | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Col... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | 74ef661b8de5be774bb96dc0c759e5e3 | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.io.*;
import java.util.*;
public class tr1 {
static PrintWriter out;
static StringBuilder sb;
static int inf = (int) 1e9;
static long mod = (long) 1e9 + 7;
static int[] si;
static ArrayList<Integer> primes;
static HashSet<Integer> pr;
static int n, k, m;
static int[] in;
static HashMap<Integer, ... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | 9d184a6f523e31030b02275d07e65028 | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | //package com.company;
import java.io.*;
import java.util.*;
public class Main {
public static class Task {
class DJS {
int[] a;
public DJS(int n) {
a = new int[n];
Arrays.fill(a, -1);
}
int find (int x) {
if (... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | 7d84dc02f06b811c0015a6aedca50acb | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | /**
* BaZ :D
*/
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class ACMIND
{
static FastReader scan;
static PrintWriter pw;
static long MOD = 1_000_000_007 ;
static long INF = 1_000_000_000_000_000_000L;
static long inf = 2_000_000_000;
public static void main(S... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | ef78275b516947797ca299ed69ed2d2c | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 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.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | 447f245d76c07bad058a6f2214db54fd | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.util.*;
import java.io.*;
public class TestD {
static BufferedReader br;
static StringTokenizer tokenizer;
public static void main(String[] args) throws Exception {
br = new BufferedReader(new InputStreamReader(System.in));
int n = nextInt();
ArrayList<Integer>[] adj = new ArrayList[n];
for(int... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | daef36ce311113909f7f896f78467369 | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]) {new Main().run();}
FastReader in = new FastReader();
PrintWriter out = new PrintWriter(System.out);
void run(){
work();
out.flush();
}
ArrayList<Integer>[] graph;
int[][] ret;
int[] degree;
int max;
void wo... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output | |
PASSED | d793637aa1bb0b669c58ba92b17c9efc | train_000.jsonl | 1576766100 | We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem.Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer fr... | 256 megabytes | //package cf1;
import java.io.*;
import java.util.*;
public class utkarsh {
BufferedReader br;
PrintWriter out;
long mod = (long) (1e9 + 7), inf = (long) (3e18);
class pair {
int L, R;
pair(int l, int r) {
L = l; R = r;
}
}
ArrayList <I... | Java | ["6\n1 2\n1 3\n3 4\n3 5\n2 6", "1"] | 2 seconds | ["9 12\n7 10\n3 11\n1 5\n2 4\n6 8", "1 2"] | null | Java 8 | standard input | [
"constructive algorithms",
"divide and conquer",
"trees",
"dfs and similar"
] | 739e60a2fa71aff9a5c7e781db861d1e | The first line contains one integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) β the number of vertices in the tree. Then $$$n - 1$$$ lines follow, each containing two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) denoting the endpoints of the $$$i$$$-th edge. It is guaranteed that the ... | 2,200 | Print $$$n$$$ pairs of integers, the $$$i$$$-th pair should contain two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i < r_i \le 2n$$$) β the endpoints of the $$$i$$$-th segment. All $$$2n$$$ integers you print should be unique. It is guaranteed that the answer always exists. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.