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 | f3860e2589740dbc86d9333fae3040d8 | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
StringBuffer sb=new StringBuffer();
int n=sc.nextInt();
int d[]=new int[n];
double d3[]=new double[n];
int count=0;
for(int i=0;i<n;i++)
{
double d1=sc.nextDouble... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | 0844fe5725673c978b6fdc81ef66f176 | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 256 megabytes |
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Solution implements Runnable
{
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private Space... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | d230558f226617739508c7ad64b579b9 | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 256 megabytes | import java.util.Scanner;
import java.util.Arrays;
public class D {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
double[] a = new double[n];
long sum = 0;
for (int i = 0; i < n; i++) {
a[i] = sc.nextDouble();
sum += (int) a[i];
}
for (int i = ... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | fefea008885436dbdf3e37245632f1c2 | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 256 megabytes | import java.io.*;
import java.util.*;
public class D implements Runnable {
public static void main (String[] args) {new Thread(null, new D(), "_cf", 1 << 28).start();}
public void run() {
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
System.err.println("");
int n = fs.n... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | 4ab712e1e0a6290fd283525b8f2d0dce | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 256 megabytes |
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;
public class mis {
public static class FastReader {
BufferedReader br;
StringTokenizer st;
//it reads the data about the ... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | 0950ea50034a97d65d8535818ade47f7 | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 256 megabytes | import java.io.*;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
public class D {
static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
static MyScanner sc = new MyScanner();
public static void main(String[] args) {
doTask();
ou... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | b7305ab2caa6d4011b9cbfd64d4485eb | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.management.MemoryType;
import java.math.BigInteger;
import java.util.*;
public class Main {
static final int INF = Integer.MAX_VALUE;
static i... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | 84b02a2f6256cb49a4919d07d3d6cc62 | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class work2
{
static FastReader s;;
static int dp[];
static PrintWriter out;
static class pair
{
double a;
int b;
pair(double x, int y)
{
a=x;
b=y;
}
}
public stat... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | b82b4fa07d9b9b8f71ab9ba7e650f49b | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 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.util.Scanner;
import java.util.StringTokenizer;
import java.util.HashMap;
public class Main
{
static class Reader
{
final privat... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | 3bc3ab6c884538adf05f64134b44b6e2 | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 256 megabytes |
import java.io.*;
import static java.lang.Double.max;
import static java.lang.Math.pow;
import java.util.*;
/**
*
* @author Mohammed M Elkady
*/
public class Mamo {
static long ans,sum,max=-99999999;
static long []ho;
static StringBuilder Sd=new StringBuilder();
static FastReader in=new FastReader();
public sta... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | 7c6159373ca5407625c22fd6d2215cb8 | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
public cl... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | d393c1b29ce77525b710e3612a94c894 | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 256 megabytes | import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
p... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | 12191d9b0755c732df55adb4c05149eb | train_002.jsonl | 1561710000 | Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other word... | 256 megabytes | import javafx.util.Pair;
import sun.net.www.content.text.Generic;
import static java.lang.Double.parseDouble;
import static java.lang.Integer.parseInt;
import static java.lang.Integer.reverse;
import static java.lang.Long.parseLong;
import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java... | Java | ["4\n4.58413\n1.22491\n-2.10517\n-3.70387", "5\n-6.32509\n3.30066\n-0.93878\n2.00000\n1.96321"] | 1 second | ["4\n2\n-2\n-4", "-6\n3\n-1\n2\n2"] | NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"math"
] | 6059cfa13594d47b3e145d7c26f1b0b3 | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the num... | 1,500 | In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any. | standard output | |
PASSED | d899466d09844882070ed0fd08bc19e7 | train_002.jsonl | 1441526400 | People in BubbleLand like to drink beer. Little do you know, beer here is so good and strong that every time you drink it your speed goes 10 times slower than before you drank it.Birko lives in city Beergrade, but wants to go to city Beerburg. You are given a road map of BubbleLand and you need to find the fastest way ... | 256 megabytes | //package bubble8;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.InputMismatchException;
import java.util.Queue;
public class G {
InputStream is;
P... | Java | ["8 10\n0 1 1\n1 2 5\n2 7 6\n0 3 2\n3 7 3\n0 4 0\n4 5 0\n5 7 2\n0 6 0\n6 7 7"] | 1 second | ["32\n3\n0 3 7"] | null | Java 8 | standard input | [
"dfs and similar",
"shortest paths"
] | f5e23ee7d82a91b4f1a2cb301e59d8ec | The first line of input contains integer N — the number of cities in Bubbleland and integer M — the number of roads in this country. Cities are enumerated from 0 to N - 1, with city 0 being Beergrade, and city N - 1 being Beerburg. Each of the following M lines contains three integers a, b (a ≠ b) and len. These number... | 2,200 | The first line of output should contain minimal time needed to go from Beergrade to Beerburg. The second line of the output should contain the number of cities on the path from Beergrade to Beerburg that takes minimal time. The third line of output should contain the numbers of cities on this path in the order they ar... | standard output | |
PASSED | 84d55e998f802160596d7cfbd81d6faa | train_002.jsonl | 1441526400 | People in BubbleLand like to drink beer. Little do you know, beer here is so good and strong that every time you drink it your speed goes 10 times slower than before you drank it.Birko lives in city Beergrade, but wants to go to city Beerburg. You are given a road map of BubbleLand and you need to find the fastest way ... | 256 megabytes | import java.util.LinkedList;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.io.BufferedReader;
import java.util.Collection;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collections;
import... | Java | ["8 10\n0 1 1\n1 2 5\n2 7 6\n0 3 2\n3 7 3\n0 4 0\n4 5 0\n5 7 2\n0 6 0\n6 7 7"] | 1 second | ["32\n3\n0 3 7"] | null | Java 8 | standard input | [
"dfs and similar",
"shortest paths"
] | f5e23ee7d82a91b4f1a2cb301e59d8ec | The first line of input contains integer N — the number of cities in Bubbleland and integer M — the number of roads in this country. Cities are enumerated from 0 to N - 1, with city 0 being Beergrade, and city N - 1 being Beerburg. Each of the following M lines contains three integers a, b (a ≠ b) and len. These number... | 2,200 | The first line of output should contain minimal time needed to go from Beergrade to Beerburg. The second line of the output should contain the number of cities on the path from Beergrade to Beerburg that takes minimal time. The third line of output should contain the numbers of cities on this path in the order they ar... | standard output | |
PASSED | eeeb6df95301a77c190ee055b321c217 | train_002.jsonl | 1441526400 | People in BubbleLand like to drink beer. Little do you know, beer here is so good and strong that every time you drink it your speed goes 10 times slower than before you drank it.Birko lives in city Beergrade, but wants to go to city Beerburg. You are given a road map of BubbleLand and you need to find the fastest way ... | 256 megabytes | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.HashMap;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.AbstractCollection;
import java.util.LinkedList;
import java.util.HashS... | Java | ["8 10\n0 1 1\n1 2 5\n2 7 6\n0 3 2\n3 7 3\n0 4 0\n4 5 0\n5 7 2\n0 6 0\n6 7 7"] | 1 second | ["32\n3\n0 3 7"] | null | Java 8 | standard input | [
"dfs and similar",
"shortest paths"
] | f5e23ee7d82a91b4f1a2cb301e59d8ec | The first line of input contains integer N — the number of cities in Bubbleland and integer M — the number of roads in this country. Cities are enumerated from 0 to N - 1, with city 0 being Beergrade, and city N - 1 being Beerburg. Each of the following M lines contains three integers a, b (a ≠ b) and len. These number... | 2,200 | The first line of output should contain minimal time needed to go from Beergrade to Beerburg. The second line of the output should contain the number of cities on the path from Beergrade to Beerburg that takes minimal time. The third line of output should contain the numbers of cities on this path in the order they ar... | standard output | |
PASSED | 304c44dfdf8176f0c951ba122cf75714 | train_002.jsonl | 1441526400 | People in BubbleLand like to drink beer. Little do you know, beer here is so good and strong that every time you drink it your speed goes 10 times slower than before you drank it.Birko lives in city Beergrade, but wants to go to city Beerburg. You are given a road map of BubbleLand and you need to find the fastest way ... | 256 megabytes | import java.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigDecimal;
import java.math.BigInteger;
import static java.lang.Math.*;
// Solution is at the bottom of code
public class G implements Runnable{
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
BufferedReader... | Java | ["8 10\n0 1 1\n1 2 5\n2 7 6\n0 3 2\n3 7 3\n0 4 0\n4 5 0\n5 7 2\n0 6 0\n6 7 7"] | 1 second | ["32\n3\n0 3 7"] | null | Java 8 | standard input | [
"dfs and similar",
"shortest paths"
] | f5e23ee7d82a91b4f1a2cb301e59d8ec | The first line of input contains integer N — the number of cities in Bubbleland and integer M — the number of roads in this country. Cities are enumerated from 0 to N - 1, with city 0 being Beergrade, and city N - 1 being Beerburg. Each of the following M lines contains three integers a, b (a ≠ b) and len. These number... | 2,200 | The first line of output should contain minimal time needed to go from Beergrade to Beerburg. The second line of the output should contain the number of cities on the path from Beergrade to Beerburg that takes minimal time. The third line of output should contain the numbers of cities on this path in the order they ar... | standard output | |
PASSED | 2e043601ea1922a553e6bcd2b15301aa | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
imp... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | c6ce65987bbfc3de377f18c3308f4a1c | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static InputReader in = new InputReader(System.in);
static PrintWriter out = new PrintWriter(System.out);
static int oo = (int)1e9;
static int mod = 1000000007;
public static void main(String[] args) throws IOException {
int tests = in.nextI... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 34ddccc825167fde4f874f85bbeac747 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static InputReader in = new InputReader(System.in);
static PrintWriter out = new PrintWriter(System.out);
static int oo = (int)1e9;
static int mod = 1000000007;
public static void main(String[] args) throws IOException {
int t = in.nextInt()... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 124c4d311df85981a2c3d640c1bd0ed2 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | d1fc37f8aaef6b1b6110cd5748fcbca5 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author nul... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 6da64d7b8acd1df5ef56fdf9f44fd507 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
private static int getPivotIndex(String s, int pivotNum) {
for (int k = s.length() - 1; k >= 0; k--)
if (s.charAt(k) - '0' < pivotNum) return k;
return -1... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 1785b7add2528095419e9d8a239c21a4 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Codechef
{ static PrintWriter out=new PrintWriter(System.out);static FastScanner in = new FastScanner(System.in);static class FastScanner {BufferedReader br;StringTokenizer stok;FastScanner(InputStream is) {br = new BufferedReader(new InputStr... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 61485fdb1808a46e065fb4fb31c349ad | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class C {
static void solve() th... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 9c64a0199c806fd3571df3d8c72eabb2 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes |
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 82b30a63af73ca9f1dc27818f428c885 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Solution implements Runnable
{
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private Space... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 364049779fc0d3145b28b18a14c85420 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.util.*;
import java.math.*;
// **** C. Paint the Digits ****
public class C {
static char [] in = new char [1000000];
public static void main (String [] arg) throws Throwable {
int t = nextInt();
StringBuilder ans = new StringBuilder(200000);
for (int ii = 0; ii<t; ++ii) {
int n = nextInt();
... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | a9dbe939116373439af16e857deac59e | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class PaintTheDigits {
public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new InputStreamReader(Sy... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 2acd12939409c5df8e5dedaa4639b51b | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class C {
public class Pair implements Comparable<Pair> {
public int dig;
public int ind;
public Pair(int dig, int ind) {
this.dig = dig;
this.ind = ind;
}
public int compareTo(Pair p) {
if(this.dig < p.dig) {
return -1;
} e... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 982f1e00ac3e2f14ee0f9a69b245e83a | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | //package test;
import java.util.*;
import java.io.*;
public class CF1 implements Runnable {
FastReader s;
PrintWriter out;
String INPUT = "";
void solve() {
//Type solution here.
int t = s.nextInt();
while(t-->0)
{
int n = s.nextInt();
String str = s.next();
char[] carr = str.toCharArray()... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 83b4dd57b30e49949122a32f7bf1a427 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.*;
import java.util.*;
public class C {
static class InputReader {
BufferedReader reader;
StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | c1cb080fd0b4fd88af011337d3ccf22f | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | /**
* Created at 22:25 on 2019-09-14
*/
import java.io.*;
import java.util.*;
public class Main {
static FastScanner sc = new FastScanner();
static Output out = new Output(System.out);
static final int[] dx = {0, 1, 0, -1};
static final int[] dy = {-1, 0, 1, 0};
static final long MOD = (long) (1e9 + 7)... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | a40f6e21eb5c20492cccfccee5e872cb | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class C {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | d944d70b29a30c3a70de545bec38bf07 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes |
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String args[])
{
Scanner scan=new Scanner(System.in);
int t=scan.nextInt();
for(int q=0;q<t;q++) {
int n=scan.nextInt();
String cur=scan.next();
int min[]=new int[n];
// int x=cur.charAt(n)
min[n-... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 98aae64bbad92300d8c8597ccfe2512f | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.util.*;
public class sol{
public static void paintdigit(String s,int n){
char carr[]=s.toCharArray();
Arrays.sort(carr);
int k=0;
int res[]=new int[n];
for(int i=0;i<s.length();i++){
if(k<s.length())
if(carr[k]==s.charAt(i)... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 7492d5354ef2bbddde4905874bd40cf8 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | e2966d6a6b2da46555f71f3da28e3e40 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class C {
public static void main(String[] args) {
// {
// System.out.println(solve("040425524644"));
// System.out.println(solve("0"));
// System.out.println(solve("123456789"));
// System.out.print... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | f36544fcdcd4e9f14e2e241016d863c2 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
MScanner sc=new MScanner(System.in);
PrintWriter pw=new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
char[]in=sc.nextLine().toCharArray();
if(n==1)... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 1ea38d4eaae7bd8bdf93538e7f6950e6 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.*;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
public class PaintTheDigits {
static Scanner sc = new Scanner(System.in);
static PrintWriter pw = new PrintWriter(System.out), pw2 = new PrintWriter(System.out);
static int n, arr[];
public static voi... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 124de050fe50951fc81a2f49a3e31da3 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
int n = sc.nextInt();
char[] d = sc.next().toCharArray();
System.out.println(solve(d)... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | a275b7edaad2247937fefbc5077c671d | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.SplittableRandom;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solu... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 599741032ad10db14eec9a4528161aeb | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.*;
import java.util.*;
public class C implements Runnable {
FastReader scn;
PrintWriter out;
String INPUT = "";
void solve() {
int t = scn.nextInt();
here: while (t-- > 0) {
int n = scn.nextInt();
String s = scn.next();
int[][] arr = new int[n][2];
int[] need = new int[n];
TreeS... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 056cd94dd506fa8c4e17cf1c8678a129 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelp... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 3570e928a1b5f9a5e8e561e42053d02f | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes |
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelp... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 22682d556e38e2164d557683b69f0ab4 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | //package cf584d12;
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class C {
public static void main(String[] args) {
MyScanner sc = new MyScanner();
int tests = sc.nextInt();
for(int wq = 0; wq < tests; wq++) {
int n = sc.nextInt();
char[] s = sc.nextLine().toCharArray();
... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | d0f392e15aa6920ff1d246c4bfda9b47 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;
import java.util.regex.Pattern;
public class ROUGH {
public static class FastReader {
BufferedReader br;
StringTokenizer st;
//it reads the data about the specified point and divide the data about it ,it is quite fast
... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 92c10c1b572ae7be73f564829755d4d6 | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner();
PrintWriter out = new PrintWriter(System.out);
int tc = sc.nextInt();
while (tc-- > 0) {
int n = sc.nextInt();
char[] s = sc.next().toCharArray();
Arr... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | 00470fb8211c837a344e9c67b87e60fa | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | import java.io.*;
import java.util.*;
public class C
{
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer tok;
public void go() throws IOException
{
StringToken... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | d9cf9e8d98f40c350f78c33470dca59e | train_002.jsonl | 1568466300 | You are given a sequence of $$$n$$$ digits $$$d_1d_2 \dots d_{n}$$$. You need to paint all the digits in two colors so that: each digit is painted either in the color $$$1$$$ or in the color $$$2$$$; if you write in a row from left to right all the digits painted in the color $$$1$$$, and then after them all the digi... | 256 megabytes | /**
* BaZ :D
*/
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main
{
static MyScanner scan;
static PrintWriter pw;
static long MOD = 1_000_000_007;
static long INF = 1_000_000_000_000_000_000L;
static long inf = 2_000_000_000;
public static void main(Strin... | Java | ["5\n12\n040425524644\n1\n0\n9\n123456789\n2\n98\n3\n987"] | 2 seconds | ["121212211211\n1\n222222222\n21\n-"] | NoteIn the first test case, $$$d=040425524644$$$. The output $$$t=121212211211$$$ is correct because $$$0022444$$$ (painted in $$$1$$$) concatenated with $$$44556$$$ (painted in $$$2$$$) is $$$002244444556$$$ which is a sorted sequence of $$$n$$$ given digits. | Java 8 | standard input | [
"constructive algorithms",
"implementation",
"greedy"
] | 886f773e75fa3c770fb70133ff1b595b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the input. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) — the length of a given sequence of digits. The next line contains a sequence of $$$n$$$ digits $$$d_1d_2 \dots ... | 1,500 | Print $$$t$$$ lines — the answers to each of the test cases in the input. If there is a solution for a test case, the corresponding output line should contain any of the valid colorings written as a string of $$$n$$$ digits $$$t_1t_2 \dots t_n$$$ ($$$1 \le t_i \le 2$$$), where $$$t_i$$$ is the color the $$$i$$$-th digi... | standard output | |
PASSED | fea744be19b7b4581c51ee4859380e1e | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes |
// Problem : C. Prime Number
// Contest : Codeforces Round #209 (Div. 2)
// URL : https://codeforces.com/contest/359/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
import java.io.*;
import java.util.*;
public class a {
public static void ma... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | 53d9736d336f26839a8ed7ea7bf4184d | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.util.*;
import java.io.*;
public class _0359_C_PrimeNumber {
public static void main(String[] args) throws IOException {
int N = readInt(), B = readInt(), arr[] = new int[N+1]; for(int i = 1; i<=N; i++) arr[i] = readInt();
long sum = 0; for(int i = 1; i<=N; i++) sum += arr[i];
PriorityQueue<Long> p... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | ff465eefcc68c57db9e76fe2a70a384b | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes |
import java.io.*;
import java.math.*;
import java.util.*;
import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;
public class C359
{
public static int mod = 1000000007;
public static long INF = (1L << 60);
static FastS... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | b938818995ba6421a9c1ef6a48ccae8c | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
public class B {
static final int mod = (int)1e9 + 7;
public static void... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | b94619378fb230dbbc3c6a0e60a8598c | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Map.Entry;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class P359C {
public static void main(String[... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | fc82702b5f3f66a705cf784535deb221 | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
public class C {
static final int mod = (int) 1e9 + 7;
public static void main(String[] args) throws... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | 77653f36a6047f25ded27602b40a2d1a | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | /*
[ ( ^ _ ^ ) ]
*/
// problem: cf/359/C
// package cf.c;
import java.io.*;
import java.util.*;
public class c {
int INF = (int)1e9;
long MOD = 1000000007;
long pow(long a, long n, long mod) {
long rs = 1;
while (n > 0) {
if (n % 2 == 1) {
rs *= a;
... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | a30da1757c0d390471d7915134be87ee | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
public class PrimeNumber
{
public static void main(String[] args)
{
new PrimeNumber(System.in, ... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | f52dd16508143394c57fa3a3198bf284 | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.AbstractCollection;
import java.util.PriorityQueue;
import java.util.AbstractQueue;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* B... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | a19f6bdadf9e821b150ce5f676453445 | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | //package a2oj_ladder_C;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | 464ac17afedaee818bb017e8a16259b9 | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.AbstractCollection;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.PriorityQueue;
import java.io.FileInputStream;
import java.io.FileNotFoundException... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | a5faef47ebe947d12f5d254c5a0aad03 | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class Main extends PrintWriter {
final Random rand = new Random(31);
final int inf = (int) 1e9;
final long linf = (long) 1e18;
final static String IO = "_std";
final int mod = inf + 7;
int modpow(int a, long p) {
... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | 90a03ffa273c461721a6eb08ca503183 | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Solution implements Runnable{
FastScanner sc;
PrintWriter pw;
final class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
try {
br = new BufferedReader(n... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | ce9059e8954764ce99e9ea6ed2fd50c9 | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.util.*;
public class PrimeNumber {
private static final long MOD=1000000007;
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
long n=sc.nextLong(),x=sc.nextLong(),sum=0;
TreeMap<Integer,Integer>pows=new TreeMap<Integer,Integer>();
for(int i=0;i<n;i++){
int a=sc.nextInt(... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | 5a738f467df3ed12968c51a69e889305 | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class PrimeNumber {
static int a[] = new int[100000+5];
static int MOD = 1000 * 1000 * 1000 + 7;
public static void main... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | 494879c9d1641eeff55aa2d5e858636a | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | //package com.company;
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
new Main().run();
}
public void run() throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
long n,x... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | 7e3c2d47d75c377a5392d5073f7c7c2c | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class problem359C{
public static void main(String[]args)throws IOException{
BufferedReader x=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer(x.readLine());
int n=Integer.parseInt(st... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | 997a7eb032d28c148e09fb76ce34f18a | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.io.IOException;
import java.util.StringTokenizer;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
pub... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | 2d37fb776b4c16941a19acebd9e12f69 | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Pradyumn Agrawal coderbond0... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | 4b4a419d5551a147f7335be776a10f7e | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | /*
*
* @Author Ajudiya_13(Bhargav Girdharbhai Ajudiya)
* Dhirubhai Ambani Institute of Information And Communication Technology
*
*/
import java.util.*;
import java.io.*;
import java.lang.*;
public class Code332
{
public static void main(String[] args)
{
InputReader in = new InputReader(System.in);
... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | bcda589bc746e7eebb66fdd36678c7f5 | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
IIO io;
Main(IIO io) {
this.io = io;
}
public static void main(String[] args) throws IOException {
ConsoleIO io = new Cons... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | 557fc9b4d057f7c1ba85365763521438 | train_002.jsonl | 1383379200 | Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number t equals xa1 + a2 + ... + an. Now Simon wants to r... | 256 megabytes | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
public class Main{
static final int MOD = (int)1e9 + 7;
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int n =... | Java | ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0"] | 1 second | ["8", "27", "73741817", "1"] | NoteIn the first sample . Thus, the answer to the problem is 8.In the second sample, . The answer to the problem is 27, as 351 = 13·27, 729 = 27·27.In the third sample the answer to the problem is 1073741824 mod 1000000007 = 73741817.In the fourth sample . Thus, the answer to the problem is 1. | Java 8 | standard input | [
"number theory",
"math"
] | 4867d014809bfc1d90672b32ecf43b43 | The first line contains two positive integers n and x (1 ≤ n ≤ 105, 2 ≤ x ≤ 109) — the size of the array and the prime number. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ a1 ≤ a2 ≤ ... ≤ an ≤ 109). | 1,900 | Print a single number — the answer to the problem modulo 1000000007 (109 + 7). | standard output | |
PASSED | 52887b1eb7aa7bfe5e3c47a668efffce | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Random;
import java.util.StringTokenizer;
public class ProblemB {
public static void main(String [] a... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 4416beedc123c75cfeb84121d52ec6fd | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
import java.lang.*;
public class CodeForcesC {
private static BufferedReader br;
public static void mapToArray(int[][] arr, int q) throws IOException {
String[] str;
for (int i = 0; i < q; i++) {
str = br.readLine().split(" ... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 721a1b33caa70f81a6e92a26f8f5e4b3 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes |
import java.io.*;
import java.util.*;
public class Solution
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int i=0;i<t;i++){
int n = in.nextInt();
int[] arr = new int[n+1];
for(int j=0;j<n;j++){
arr[j]=in.nextInt();
... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | c83d70a7cd2dd7516623828bcccc1ccd | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main
{
public static void main(String[] args) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pwr = new PrintWriter(System.out);
int t = Integer.parseInt(br.readLine());
w... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 7ff1562b2429683e45461666590f09d3 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while(t-- > 0){
int n = scan.nextInt();
int num = scan.nextInt();
long sum = 0;
sum += nu... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 52319676a2207806ea09fa8dd254f5ec | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class subseq {
static Queue<Long> q1 = new LinkedList<>();
public static void solve(long no, long[] arr) {
Queue<Long> q = new LinkedList<>();
long maxpo,sum = 0, j;
for ( int i = 0; i< no; ) {
... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | f0145845a3c7a7bbd7e1f760b87dc2e1 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class CP {
static long startTime;
static long endTime;
static Boolean [] prime ;
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public ... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | ee76a21dc4a1625ec27c74ce10387096 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class CP {
static long startTime;
static long endTime;
static Boolean [] prime ;
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public ... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 5aef5342ce4f372159a8f94c83d2f516 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class CP {
static long startTime;
static long endTime;
static Boolean [] prime ;
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public ... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 3807512f0dd194ee7651130fb26c85a5 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.*;
public class Solution{
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
StringBuffer sb = new StringBuffer();
while(t-->0){
int n = sc.nextInt();
long[]arr = new long[n];
for(int ... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | b5c2a60e9ebea74839047f200da4bac4 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.*;
public class Q3 {
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];
for (int i = 0; i < n; i++) {
a[i] ... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 6b84b8d880b8bc072a633db5160fca8a | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.io.OutputStreamWriter;
import java.io.InputStreamReader;
import java.io.FileOutputStream;
public class AlternatingSub{
public static void main(String[] args)throws IOException{
Fast... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 48258cda2cb696a5a1449ad47bd53252 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.Scanner;
public class Abhi {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
for(int k = 0; k<t; k++) {
int n = s.nextInt();
int[] a = new int[n];
int[] b = new int[n];
int m = 0;
for(int i = 0; i<n; i++) {
... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | eca83ffbcb34ca8f7608f12d86a0cca2 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.*;
public class kefas{
public static int sig(long x){
if(x>0) return 1;
else return -1;
}
public static void main(String[] args) {
Scanner q=new Scanner(System.in);
long testcases=q.nextLong();
while(testcases-->0){
int n=q.nextInt();
long[] a=new long[n];
for(int i=0;i<n;i++){
a... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 946908070b3a83c37e459db8679dafd1 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
import java.util.stream.*;
public class Solution {
/*get indexes
List<Integer> indexes = IntStream.range(0, a.length).boxed()
.filter(r -> ... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 0fd31532945d496d48d729ca1594e003 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.Scanner;
public class As_1343C {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
for (int i = 0; i < t; i++) {
int n = scanner.nextInt();
long[] x;
x = new long[n];
long sum = 0;
f... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 185302e9bb20b27b8e410b202ed92aba | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.io.PrintWriter;
import java.util.*;
import java.util.Scanner;
public class AltSubsequence {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
for (int i1 = 0; i1 < t; i1 ++){
... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 306afb8dcc11c96a049a124b69c77eeb | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.io.PrintWriter;
import java.util.*;
import java.util.Scanner;
public class AltSubsequence {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
for (int i1 = 0; i1 < t; i1 ++){
... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 3f571a53862d301ddb3185bc1fb9b588 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.io.PrintWriter;
import java.util.*;
import java.util.Scanner;
public class AltSubsequence {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
for (int i1 = 0; i1 < t; i1 ++){
... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | c167f40ac8cbee6ccc9519aa1f04e86b | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | //package com.company;
//-------------------------------------------># DEVIL CODER # -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import javax.swing.*;
import java.lang.reflect.Array;
impor... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 631c0b94299ea45a22aeea6eb7a010eb | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | //I AM THE CREED
/* //I AM THE CREED
/* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
public class Main{
public static void main(String[] args) throws IOExceptio... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 5d616776db5483f7e71f0f96e2605d31 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes |
/* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
import java.awt.*;
public class HelloWorld{
public static void main(String[] ar... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | c9e522c308b844ead6a6c93240bd8544 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.Scanner;
public class AltenatingSequence {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
while(t-->0)
{
int n = scn.nextInt();
long[] arr = new long[n];
for(int i = 0; i< arr.length; i++)
... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 0fe154271e0ab4a97e360c2e9349c9be | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
int t=in.nextInt();
while(t-->0)
{
int s=in.nextInt();
long a[]=new long[s];
int i;
for(i=0;i<s;i++)
a[i]=in.nextLong();
... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | f2fe2baa67eaf8303bb1d072c9534ab3 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main
{
public static void main(String[] args) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pwr = new PrintWriter(System.out);
int t = Integer.parseInt(br.readLine());
w... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 763df2f836de67aa62ec3244bbe42d78 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main
{
public static void main(String[] args) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pwr = new PrintWriter(System.out);
int t = Integer.parseInt(br.readLine());
w... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 6aa8c12fdf2462b1ce0cfd81b4a7d601 | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner input =... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output | |
PASSED | 0ca06f1ffea383138421947ea80edb1d | train_002.jsonl | 1587479700 | Recall that the sequence $$$b$$$ is a a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For example, if $$$a=[1, 2, 1, 3, 1, 2, 1]$$$, then possible subsequences are: $$$[1, 1, 1, 1]$$$, $$$[3]$$$ and $$$[... | 256 megabytes |
import java.util.*;
public class CodeForces {
static int max = 200005;
static int moves =1;
static ArrayList<Integer>list;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int test = input.nextInt();
while(test-->0){
int n = input.nextInt();
long sum =0;
long arr[]... | Java | ["4\n5\n1 2 3 -1 -2\n4\n-1 -2 -1 -3\n10\n-2 8 3 8 -4 -15 5 -2 -3 1\n6\n1 -1000000000 1 -1000000000 1 -1000000000"] | 1 second | ["2\n-1\n6\n-2999999997"] | NoteIn the first test case of the example, one of the possible answers is $$$[1, 2, \underline{3}, \underline{-1}, -2]$$$.In the second test case of the example, one of the possible answers is $$$[-1, -2, \underline{-1}, -3]$$$.In the third test case of the example, one of the possible answers is $$$[\underline{-2}, 8,... | Java 11 | standard input | [
"dp",
"two pointers",
"greedy"
] | 39480cdf697fc9743dc9665f989077d7 | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$... | 1,200 | For each test case, print the answer — the maximum sum of the maximum by size (length) alternating subsequence of $$$a$$$. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.