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 | f8076f682ba107ac0112f8b8cc6bf283 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class Array_Recovery {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0) {
int n = sc.nextInt();
int [ ] arr = new int[n];
for(int i = 0 ; i < n ;i++)... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | cdbd91039c17549fe767f0153b29f022 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class ProblemB {
public static void main(String[] args) {
var sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int[] d = new int[n];
int[] a = new int[n];
for (int i ... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 45dac95364ea00eaae15e8f0fe44826b | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class ProblemB {
public static void main(String[] args) {
var sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int[] d = new int[n];
int[] a = new int[n];
for (int i ... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 62ae7932516a2e3a7f49d39197a1e073 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
public class elevator
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
int d[]=new int[n];
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | a0c637d6fee5118fcebc9b1da9757db5 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import com.sun.security.jgss.GSSUtil;
import com.sun.source.tree.ModuleTree;
import org.w3c.dom.ls.LSOutput;
import java.io.*;
import java.security.spec.RSAOtherPrimeInfo;
import java.sql.Array;
import java.util.*;
public class edu130 {
static class FastReader {
BufferedReader br;
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 7e832bf7c84044e289d6810be4db1774 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes |
import java.util.*;
// B. Array Recovery
public class Main {
static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int test_case = scanner.nextInt();
scanner.nextLine();
while (test_case > 0) {
solve();
test_ca... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | b95079884113ea67de02aa1101a6acdb | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*;
import java.lang.*;
import java.util.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Array_Recovery {
public static Scanner scn = new Scanner(System.in);
public static void helper() {
int n = scn.nextInt();
int[] arr = new int[n];
fo... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 6240691a8bbe441ad49723a5cb14b2b6 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes |
import java.util.Scanner;
public class ArrayRecovery {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt();
int arr[]= new int[n];
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | c8d8b6777c146b3931eed50cc0c6bc4c | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes |
/*
_oo0oo_
o8888888o
88" . "88
(| -_- |)
0\ = /0
___/`---'\___
.' \\| |// '.
/ \\||| : |||// \
/ _||||| -:- |||||- \
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | a81f4a802a1447372bcae536ec5fe614 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.ArrayList;
import java.util.Scanner;
public class Array_Recovery {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t= sc.nextInt();
while(t>0){
int n = sc.nextInt();
int arr[] = new int[n];
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | df87de6cd95a6faafa3b526e617f4848 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*;
import java.util.*;
public class Main{
public static void main (String[] args){
// your code goes here
Scanner scn = new Scanner(System.in);
int t=scn.nextInt();
while(t-->0){
int n=scn.nextInt();
int[] d=new int[n];
for(int i=0;i<n;i++){
d[... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 7bf72a9409dc4f382f80d2d993bbb5ec | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Random;
import java.util.StringTokenizer;
/*
*/
public cla... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 0e3a04611625e33c680020d4f8cf10b3 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.invoke.MethodHandles;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
imp... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 90c95afe39f91fc9f5112cbf4df73a96 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class ArrayRecovery {
public static boolean contains(int[] d, int a) {
for (int i = 0; i < d.length; i++) {
if (d[i] == a) {
return true;
}
}
return false;
}
public static void ArrayRecovery(int n, int[] d) {
int[] a = new int[n];
a[0] = d[0];
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 5dfbe6adc2ae360cf01e18b0833a19b4 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class CF1739B {
public static void main(String[] args) throws FileNotFoundException {
//File file = new File("D:\\projects\\dsANDalgo\\src\\main\\java\\codeforce\\problemset\\testdata\\CF1739B.txt");
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | ba71e73f874b675d28d1c665f96163ee | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class B {
static class Pair1{
Integer key=0;
Integer val=0;
public Pair1(int key,... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 43abbfd691498a96b765ccd5163d5d26 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes |
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
static final int INF = 0x3f3f3f3f;
static final long LNF = 0x3f3f3f3f3f3f3f3fL;
public static void main(String[] args) throws IOException {
initReader();
int t=nextInt();
while (t--!=... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 1d639e5aed26cfb542b785d962a9e991 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import com.sun.source.tree.Tree;
import java.util.*;
import java.io.*;
import java.math.*;
public class Codechef {
static class pair{
int first;
int second;
pair(int first,int second){
this.first=first;
this.second=second;
}
}
static... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 8af51b0a36a9d3723b6a171f51933dc7 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class B {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while (t-->0){
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 30b9b55fc7d5e61a44851cab45218fcc | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static int INF = 0x3f3f3f3f, mod = 1000000007, mod9 = 998244353;
public static void main(String args[]){
try {
PrintWriter o = new PrintWriter(System.out);
boolean multiTest = true;
// init
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | a9e94c10919f71c16ed73a9edabdf575 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class BTest {
public static void method1(int[] d) {
boolean ok = false;
int[] a = new int[d.length];
a[0] = d[0];
if(a.length >= 2) {
if(a[0] >= d[1] && d[1] != 0) {
ok = true;
}
}
f... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 54235dcc6b175c56630b1d9cefbaa98a | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | // Working program using Reader Class
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Scanner;
import java.util.StringTokenizer;
//====== ++++++++ +++++++ |\ /| |+++ | ... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | c1d76b9fc1195096f9794ee981e7079f | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
FastScanner in = new... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 7c26a9be1b79946c43ad9c58f24939b8 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | // import java.lang.reflect.Array;
// import java.math.BigInteger;
// import java.nio.channels.AcceptPendingException;
// import java.nio.charset.IllegalCharsetNameException;
// import java.util.Collections;
// import java.util.logging.SimpleFormatter;
// import java.util.regex.Matcher;
// import java.util.regex... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | a10ec370691e4fe84a546154dd596e19 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class ArrayRecovery {
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTok... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 3cd745fe905705f32782e51d63a76f84 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class cp {
public static void main(String[] args) {
int t = inp();
while(t-->0){
int n = inp();
var a = inp(n);
var ans = true;
var d = new int[n];
d[0]=a[0];
for(int i=1;i<n;++i){
d[i]=d[i-1]+a[i];
}
for(int i=1;i<n;++i){
if(d[i-1]>=a[i]&&a[... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 77b8c97dc2ebfab8d05346f6316c1575 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | /***** ---> :) Vijender Srivastava (: <--- *****/
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
static FastReader sc =new FastReader();
static PrintWriter out=new PrintWriter(System.out);
static long mod=(long)32768;
static StringB... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 15ec289478986e54d9d82dc57bcea568 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution{
public static void main(String args[])throws IOException{
InputStreamReader read = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(read);
int t = Integer.parseInt(br.readLine());
while(t-->0)... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 28a12a4cfac6ab725e10a807a5a236ef | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | /* ROHAN SHARMA */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class B
{
public static final FastScanner sc = new FastScanner();
public static void main (String[] args)
{
solveB();
}
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 79abc9114d247f027b9eeec9ceb9a174 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
import java.io.*;
public class B_Array_Recovery {
// For fast input output
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{ try {br = new BufferedReader(
new FileReader("input.txt"));
PrintStream out = new PrintStream(new Fi... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 70138873dbfc62bf67395fc7f387424c | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner ( System.in);
int t=sc.nextInt();
for( int i=0;i<t;i++){
int n=sc.nextInt();
int arr[]=new int[n... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | b47834999de1f9e317b1156bb1786cda | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class Main {
public static boolean onearronly(int n, int[] d) {
int current = d[0];
for(int i = 1; i < n; i++) {
if(current - d[i] >= 0 && d[i] != 0) {
return false;
}
current += d[i];
}
return... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | de24a7680cd29831361b23ffba2189be | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.lang.*;
import java.io.*;
import java.util.*;
public class codeforces {
public static void main(String[] args) throws IOException {
// if (System.getProperty("ONLINE_JUDGE") == null) {
// PrintStream ps = new PrintStream(new File("output.txt"));
// InputSt... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 3cc089a56101bd2579048a60e3f8003b | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | /**
* Created by Himanshu
**/
import java.util.*;
import java.io.*;
public class B1739 {
static final int ALPHABET_SIZE = 26;
public static void main(String[] args) throws IOException {
PrintWriter out = new PrintWriter(System.out);
Reader s = new Reader();
int t = s.i();... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 3b44d2a54df4e71fa58e7abe1816290a | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
while(n>0){
int k=sc.nextInt();
int[] arr=new int[k];
for(int i=0;i<k;i++){
arr[i]=sc.nex... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 4a976b83362889d1785dcf8b4afa8a06 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import com.sun.security.jgss.GSSUtil;
import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.List;
public class MainClass {
static FastScanner fs;
static FastWriter fw;
static boolean checkOnlineJudge = System.getProperty("ONLINE_JUDGE") == n... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 827f70366cd85a4a13b76628d65c06c6 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.*;
public class Solver {
public static void main(String[] args) {
FastReader in = new FastReade... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 80fa09048f8658998ec129cba5b30e7d | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | //some updates in import stuff
import java.util.*;
import java.io.*;
import java.math.*;
import static java.lang.Math.*;
//key points learned
//max space ever that could be alloted in a program to pass in cf
//int[][] prefixSum = new int[201][200_005]; -> not a single array more!!!
//never allocate memo... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 998d19fbc9e69b52fa045279d3c1ee46 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class two {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner key=new Scanner(System.in);
int t=key.nextInt();
for(int i=0;i<t;i++) {
int f=0;
int n=key.nextInt();
int []d=new int[n+1];
for(int j=1;j<=n;j++) {
d[j]=key.nextInt();
}
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | b0ac1cf9d867af8f4a767a718baea3d5 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static in sc;
public static void main(String[] args) throws Exception{
try {
System.setIn(new FileInputStream("input.txt"));
System.setOut(new PrintStream(new FileOutputStream("output.txt")));
} catch (E... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | ff1c9683863c01d59c39e40cf1c516f9 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
import java.io.*;
public class practice {
static char vowels[] = new char[]{'a', 'e', 'i', 'o', 'u'};
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new Prin... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | a7d6e9b7cd04e240ef5be21f0dd226dc | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner kb = new Scanner(System.in);
int t = kb.nextInt();
while(t-- > 0)
{
int n = kb.nextInt();
int [] arr = new int[n];
for(int i=0;i<n;i++)
{
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | f591f54636f0dc79382e284e9213ac70 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes |
import java.util.*;
public class Codeforces {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while (t-- > 0) {
int n = in.nextInt();
int []d = new int[n];
for (int i = 0;i<n;i++) d[i]=in.nextInt();
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 7cf55796670a73acb65e6d02ad712347 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class Solution {
public static void main(String[] args) throws java.lang.Exception {
Scanner in = new Scanner(System.in);
int testcases = in.nextInt();
while (testcases-- > 0) {
int n = in.nextInt();
int a[] = new int[n];
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 6abbbec66cdeebbf8e4bb3c592944e72 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class ECR136B {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
G:
for (int i = 0; i < t; i++) {
int n = in.nextInt();
int[] d = new int[n];
for (int j = 0; j < n; j++) {
d[j] = in.nextInt();
}
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | a32c5306684a264ee4651ac7f88101ba | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class Solution {
static Scanner sc = new Scanner(System.in);
public static void solve() {
int size = sc.nextInt() ;
int arr [] = new int [size] ;
for (int i = 0; i < size; i++) {
arr[i] = sc.nextInt();
}
in... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | ab5259f80435d53c7fdd8f6fe2e8f87b | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
public class B {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
for (int i = 0; i < t; i++) {
int n = scanner.nextInt();
int x[] = new int[n];
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | c21d180b67d5a20a3157baf4483d5f44 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*;
import java.util.*;
public class ProblemD {
static ArrayList<Integer>res ;
public static void main(String[] args) throws Exception {
Scanner in = new Scanner();
StringBuilder sb = new StringBuilder();
int test = in.readInt();
while(test-->0){
int n = in.readInt();
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | be3fc95d1ad64081ea8912a8afbe0378 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*;
import java.util.*;
public class ProblemD {
static ArrayList<Integer>res ;
public static void main(String[] args) throws Exception {
Scanner in = new Scanner();
StringBuilder sb = new StringBuilder();
int test = in.readInt();
while(test-->0){
int n = in.readInt();
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | b2916854b25817fba9228db8e314933c | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0){
int n = sc.nextInt();
int[] arr = new int[n];
boolean ans = true;
for(int i = 0; ... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | fccc6cdbbbbe139c06bfc194e82cb810 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class B_Array_Recovery
{
public static void main(String[]args)
{
Scanner x=new Scanner (System.in);
int t=x.nextInt();
while(t-->0)
{
int n=x.nextInt();
int a[]=new int[n];
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 058becea1b43df84bd57dda046208dba | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java .util.*;
public class RecoverArray {
public static void main(String[] args) {
Scanner sc=new Scanner (System.in);
int f=sc.nextInt();
while(f-->0)
{int n=sc.nextInt();
int[] d=new int[n];
int[] a=new int[n];
for(int i=0;i<n;i++)
d[i]=... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 2065b868fdf6cbb0db3b21326b97d09f | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java .util.*;
public class RecoverArray {
public static void main(String[] args) {
Scanner sc=new Scanner (System.in);
int t=sc.nextInt();
while(t-->0)
{int n=sc.nextInt();
int[] d=new int[n];
int[] a=new int[n];
for(int i=0;i<n;i++)
d[i]=... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | f4c6831920e75fdcbe61c1eac3a42ecf | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class HelloWorld {
public static void main(String args[]) {
Scanner scanner=new Scanner(System.in);
int t=scanner.nextInt();
while(t-->0) {
int n=scanner.nextInt();
int[] nums=new int[n];
for(int i=0;i<n;i++) {
nums[i]=scanner.nextInt();
}
int[] a=ne... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | b3ef3619a09463f907bfda9f417990bd | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | /*
IF I HAD CHOICE, I WOULD HAVE BEEN A PIRATE, LOL XD ;
_____________#############
_____________##___________##
______________#____________#
_______________#____________#_##
_______________#__###############
_____##############______________#
_____##____________#_____################
______#______##########... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 883476aa1636a2ef9e249e6b0cf81124 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt(); //число наборов входных данных
for(int i = 0; i < t; i++){
int n = in.nextInt(); // размер массива
int[] d = new ... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 8fd558f7d25c8bac46d7fdff5e4acff6 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
public class Main {
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer,... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | a02858c054578ac80da4c7e930ae949b | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.Math.PI;
import static java.lang.Math.min;
import static java.lang.System.arraycopy;
import static java.lang.System.exit;
import static java.util.Arrays.copyOf;
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | ef691e3db4bf1e563dbcb2b0a5e4b9ee | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt();
int[] arr = new int[n];
for(int i=0;i<n;i++){
arr[i] = sc.nextInt();
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 292c075f332abf43a2f0b8c198bb103f | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class cf22 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
aa :
for(int i=1;i<=T;i++) {
int n = sc.nextInt();
int d[] = new int[n];
int a[] = new int[n];
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | f30e43d6d74ea3081de5934b23ba4f98 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class b implements Runnable{
static ContestScanner in = new ContestScanner();
static ContestPrinter out = new ContestPrinter();
public static void main(String[] args) {
new Thread(null, new b(), "main", 1<<28).start();
}
public void run() {
i... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 8642793cf0709690282806be6f2fac6b | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes |
import java.util.*;
import java.lang.*;
import java.io.*;
public final class Main {
FastReader s;
// PrintWriter out ;
public static void main(String[] args) throws java.lang.Exception {
new Main().run();
}
void run() {
// out = new PrintWriter(new OutputS... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | f68016c15d0ec062bac4b49bd4a98379 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | //Code By KB.
import java.io.*;
import java.lang.annotation.Target;
import java.lang.reflect.Array;
import java.security.KeyStore.Entry;
import java.util.*;
import java.util.logging.*;
import java.io.*;
import java.util.logging.*;
import java.util.regex.*;
import javax.swing.plaf.basic.BasicBorders.SplitP... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | ddad8a9dbfb8203e302e50d3a85a587a | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int[] arr = sc.nextIntArray(n);
int[] ans = new int[n];
ans... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | a49eddf281444955759398de2ebbd85d | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*;import java.lang.*;import java.util.*;
//* --> number of prime numbers less then or equal to x are --> x/ln(x)
//* --> String concatenation using the + operator within a loop should be avoided. Since the String object is immutable, each call for concatenation will
// result in a new String object ... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 00a89d9f5cf3fde906b8401bf0fcb890 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
static long mod = (int)1e9+7;
// static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
public static void main (String[] args) throws java.lang.Exception
{
FastReader sc =new FastReader();
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 289c4397af355ef9216e51f9898766c1 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | // Jai Shree Ram ⛳⛳⛳
// Jai Bajrang Bali
// Jai Saraswati maa
// Har Har Mahadev
// Thanks Kalash Shah :)
import java.math.BigInteger;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Character.isUpperCase;
public c... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 294e71455b8384b43bb66fd19e975ea5 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | //۰۪۫A۪۫۰۰۪۫B۪۫۰۰۪۫D۪۫۰۰۪۫-۪۫۰۰۪۫A۪۫۰۰۪۫L۪۫۰۰۪۫L۪۫۰۰۪۫A۪۫۰۰۪۫H۪۫۰
import java.util.*;
public class Main {
static Scanner z = new Scanner(System.in);
public static void main(String[] args) {
int M=z.nextInt();
while(M-->0){
int N =z.nextInt();
int a[]=new int [N];
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 7c6a445b9e4b4213fa0f39db3deb67e5 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*;
import java.util.*;
public class B
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int t = Integer.parseInt(sc.next().trim());
String sol = "";
for (int i = 0; i<t; ++i)
{
sol = "";
int n = Integer... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 423add4320ba91d5ce66e471f3292d29 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class cc {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int testcase = scan.nextInt();
for(int v = 0 ; v < testcase; v++){
int n = scan.nextInt();
int []arr = new int[n];
for... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 3cbd2c7e8495c64e8c81bfc16d26a295 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class B_Array_Recovery {
public static void main(String[] args) {
try {
FastReader s = new FastReader();
int t = s.nextInt();
while (t-- > 0) {
int a=0;
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 0d56a0092a75a67ed0b1572b4781a4da | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class Recovery
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
byte t=sc.nextByte();
for(byte i=0; i<t; i++)
{
int n=sc.nextInt(), d[]=new int[n], a[]=new int[n];
for(int j=0; j<n; j+... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | ff3ee754044b1588bb01e8ea2c0cbb6a | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes |
import java.util.*;
public class Solution {
static Scanner scn = new Scanner(System.in);
public static void main(String[] args) {
int t = scn.nextInt();
int temp = t;
while (t-->0) {
int n = scn.nextInt();
int[] arr = new int[n];
int[]... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 585daa828b9624ded0a4489b18555ce9 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | // Working program with FastReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
public class UtopianLord {
stat... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 1d49a46a5e414b9c41a081ad3444651c | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int test=sc.nextInt();
for(int tc=0; tc<test; tc++) {
int n=sc.nextInt();
int[] d=new int[n];
for(int i=0; i<n; i++) {
d[i]=sc.nextInt();
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 84e15b8b555b2cc8797105968ef6e902 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class Solution{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt();
int d[] = new int[n];
int a[] = new int[n];
for(int i... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | c88c0d29b95ce7027e3217a43ad71ed5 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
static final PrintWriter out =new PrintWriter(System.out);
static final FastReader sc = new FastReader();
//I invented a new word!Plagiarism!
//Did you hear about the mathematician who’s afraid of negative numbers?He’l... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 2fff5a709ea7a3fb7d3af3b0a2938dcd | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*; import java.util.*;
public class Main
{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int t = Integer.parseInt(br.readLine());
while(t-->0){
int n = Integ... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | bf8682ce8cc95247d1a1b44801b8146c | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes |
import java.util.*;
import java.io.*;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
outer: while(t-->0) {
int n = sc.nextInt();
int[] d = new int[n];
int[] ans = new... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 2fac5143a10f8eb019f1b5daddb07b47 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes |
import java.util.*;
import java.io.*;
public class Main {
private static FS sc = new FS();
private static class FS {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | fc464d85a9a2e8b53559649bd95c94ce | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
private static final void solve() throws IOException {
final int n = ni();
var a = ni(n);
var d = a.clone();
Arrays.parallelPrefix(d, Integer::sum);
for (int i = 1; i < n; i++) {
if (a[i] != 0 && d[i - 1] ... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 6ae6ccb139e4c9a30a6970733e03285a | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class Array_Recovery {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
for (int i = 0; i<t; i++){
int[] testList = new int[sc.nextInt()];
sc.nextLi... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | d17c3338ed745a021d330ab724c64a14 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static int gcd(int a, int b) {
if(b == 0)
return a;
return gcd(b, a % b);
}
public static void main(String[] args) {
int t;
Scanner scn = new Scanner(System.in);
t = scn.nextIn... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 183bc0ae0aba1475c3c1851a0b43c5e4 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | //package kg.my_algorithms.Codeforces;
import java.util.*;
import java.io.*;
public class Solution {
private static final int[][] knightMoves = {{1,2},{-1,2},{1,-2},{-1,-2},{2,1},{-2,1},{2,-1},{-2,-1}};
private static final FastReader fr = new FastReader();
public static void main(String[] args) thr... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 405fbc1d18263a08744e5d5cdbf8ee85 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class Main2 {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int t= Integer.parseInt(scn.nextLine());
for (int i = 0; i < t; i++) {
int size = Integer.parseInt(scn.nextLine());
int[] d = new int... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 9d38406c6c2a12b6126d022d5fc3d9af | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
import static java.lang.Math.round;
public class sol{
public static void main(String args[])
{
// https://codeforces.com/problemset/problem/1566/C
// https://codeforces.com/problemset/problem/1739/B
Scanner sc=new Scanner(System.in);
int t=sc.nextI... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | ec6430cc848efe4b015f5a8111be21e1 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class Main
{
static int check(int[] arr , int a,int x,int max){
boolean x1=false;
if(x<=0) return -1;
for(int i=x;i>=0;i--){
int gcd=0;
//int lcm = Math.max(arr[i],arr[x]);
for(int j=1;j<=arr[i] && j... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 1a556019db10d26d4c9e44e528faee08 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
import java.io.*;
public class User {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String [] line = br.readLine().split(" ");
int t = Integer.parseInt(line[0]);
for(... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 87c8367de0d0c1d2977b30eaaf5a9cd0 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class TaskB {
public static void main(String[] args) {
FastReader reader = new FastReader();
int tt = reader.nextInt();
// int tt = 1;
for (; tt > 0; ... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 4181f8ff3ce16ab8ae3f83a791038515 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class TaskB {
static int[] result = null;
public static void main(String[] args) {
FastReader reader = new FastReader();
int tt = read... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | ae701e5cab070e2e9dfb45b836a01109 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class Codechef_Contest_2 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
ArrayList<Integer> a=new ArrayList<>();
int n=sc.nextInt();
while(n>0){
int k=sc.nextInt();
int p=0;
int h=... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 69f84094e526f9fb8aba8fa6534ff6f7 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class BroCoders {
static Scanner sc=null;
public static void main(String[] args) {
sc = new Scanner(System.in);
int t=sc.nextInt();
while(t-->0) {
solve();
}
}
public static void solve(){
int n=sc.nextInt();
int d[]=new int[n];
for(int i=0;i<n;... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 91a6cfd9e7a8fe9006ae1c686ace06a6 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
try (Kattio reader = new Kattio()) {
int t = reader.nextInt();
Outer: while (t-- > 0) {
int n = reader.nextInt();
int[] A = new int[n];
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | df931138d5ba823f21acb07f132d0be6 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class B {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int nbCases = scanner.nextInt();
for (int testCase = 0; testCase < nbCases; ++testCase) {
int arraySize = scanner.nextInt();
bo... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 3d53d6820a908b4d8a5ba39c1139d838 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.Scanner;
public class ArrayRecovery {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int test = scan.nextInt();
while(test-- >0)
{
int n = scan.nextInt();
long [] d = new long[n];
fo... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | e9ffe9e9da9116f0ae107acf18bd70b5 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes |
import java.util.*;
import java.io.*;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.*;
import static java.lang.System.*;
public class CP0026 {
public static void main(String args[]) throws Exception {
PrintWriter pw = new PrintWriter(out);
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | a3c580f5c286aee70c777ba7c3dbcd5f | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
int a[]=new int[n];
int temp[]=new int[n];
int temp1[]=new int[n];
int c=0;
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | fafe75e7aa5cdb348b1a8ac50dac4957 | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes |
import java.util.*;
public class ArrayRecovery {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int t=s.nextInt();
for (int i = 0; i < t; i++) {
int n=s.nextInt();
int[] d=new int[n];
int[] a=new int[n];
... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | e2462f8a3ef904eb698ace17ffb1a98f | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | /* package codechef; // don't place package name! */
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of ... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output | |
PASSED | 59da77ced49c8632665c8731b23d8aeb | train_109.jsonl | 1664462100 | For an array of non-negative integers $$$a$$$ of size $$$n$$$, we construct another array $$$d$$$ as follows: $$$d_1 = a_1$$$, $$$d_i = |a_i - a_{i - 1}|$$$ for $$$2 \le i \le n$$$.Your task is to restore the array $$$a$$$ from a given array $$$d$$$, or to report that there are multiple possible arrays. | 256 megabytes | /* package codechef; // don't place package name! */
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of ... | Java | ["3\n\n4\n\n1 0 2 5\n\n3\n\n2 6 3\n\n5\n\n0 0 0 0 0"] | 2 seconds | ["1 1 3 8\n-1\n0 0 0 0 0"] | NoteIn the second example, there are two suitable arrays: $$$[2, 8, 5]$$$ and $$$[2, 8, 11]$$$. | Java 17 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | f4b790bef9a6cbcd5d1f9235bcff7c8f | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the arrays $$$a$$$ and $$$d$$$. The second line contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_i \le ... | 1,100 | For each test case, print the elements of the array $$$a$$$, if there is only one possible array $$$a$$$. Otherwise, print $$$-1$$$. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.