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
a80d536938afcee48413246611a73198
train_001.jsonl
1553267100
For a given set of two-dimensional points $$$S$$$, let's denote its extension $$$E(S)$$$ as the result of the following algorithm:Create another set of two-dimensional points $$$R$$$, which is initially equal to $$$S$$$. Then, while there exist four numbers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$ and $$$y_2$$$ such that $$$(x_...
1024 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numCh...
Java
["7\n1 1\n1 2\n2 1\n2 2\n1 2\n1 3\n2 1"]
3.5 seconds
["1 2 4 4 4 6 3"]
null
Java 8
standard input
[ "data structures", "dsu", "divide and conquer" ]
feff009596baf8e2d7f1aac36b2f077e
The first line contains one integer $$$q$$$ ($$$1 \le q \le 3 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ lines follow, each containing two integers $$$x_i$$$, $$$y_i$$$ ($$$1 \le x_i, y_i \le 3 \cdot 10^5$$$), denoting $$$i$$$-th query as follows: if $$$(x_i, y_i) \in S$$$, erase it from $$$S$$$, otherwise in...
2,600
Print $$$q$$$ integers. $$$i$$$-th integer should be equal to the size of $$$E(S)$$$ after processing first $$$i$$$ queries.
standard output
PASSED
9ada8324c6e45445fe80147406208543
train_001.jsonl
1553267100
For a given set of two-dimensional points $$$S$$$, let's denote its extension $$$E(S)$$$ as the result of the following algorithm:Create another set of two-dimensional points $$$R$$$, which is initially equal to $$$S$$$. Then, while there exist four numbers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$ and $$$y_2$$$ such that $$$(x_...
1024 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numCh...
Java
["7\n1 1\n1 2\n2 1\n2 2\n1 2\n1 3\n2 1"]
3.5 seconds
["1 2 4 4 4 6 3"]
null
Java 8
standard input
[ "data structures", "dsu", "divide and conquer" ]
feff009596baf8e2d7f1aac36b2f077e
The first line contains one integer $$$q$$$ ($$$1 \le q \le 3 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ lines follow, each containing two integers $$$x_i$$$, $$$y_i$$$ ($$$1 \le x_i, y_i \le 3 \cdot 10^5$$$), denoting $$$i$$$-th query as follows: if $$$(x_i, y_i) \in S$$$, erase it from $$$S$$$, otherwise in...
2,600
Print $$$q$$$ integers. $$$i$$$-th integer should be equal to the size of $$$E(S)$$$ after processing first $$$i$$$ queries.
standard output
PASSED
dd6e2b3b5f3f6d175a39efd4a2754d69
train_001.jsonl
1553267100
For a given set of two-dimensional points $$$S$$$, let's denote its extension $$$E(S)$$$ as the result of the following algorithm:Create another set of two-dimensional points $$$R$$$, which is initially equal to $$$S$$$. Then, while there exist four numbers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$ and $$$y_2$$$ such that $$$(x_...
1024 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Main implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numCh...
Java
["7\n1 1\n1 2\n2 1\n2 2\n1 2\n1 3\n2 1"]
3.5 seconds
["1 2 4 4 4 6 3"]
null
Java 8
standard input
[ "data structures", "dsu", "divide and conquer" ]
feff009596baf8e2d7f1aac36b2f077e
The first line contains one integer $$$q$$$ ($$$1 \le q \le 3 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ lines follow, each containing two integers $$$x_i$$$, $$$y_i$$$ ($$$1 \le x_i, y_i \le 3 \cdot 10^5$$$), denoting $$$i$$$-th query as follows: if $$$(x_i, y_i) \in S$$$, erase it from $$$S$$$, otherwise in...
2,600
Print $$$q$$$ integers. $$$i$$$-th integer should be equal to the size of $$$E(S)$$$ after processing first $$$i$$$ queries.
standard output
PASSED
7423d0ef1dca35ccbb6fc016d354a478
train_001.jsonl
1553267100
For a given set of two-dimensional points $$$S$$$, let's denote its extension $$$E(S)$$$ as the result of the following algorithm:Create another set of two-dimensional points $$$R$$$, which is initially equal to $$$S$$$. Then, while there exist four numbers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$ and $$$y_2$$$ such that $$$(x_...
1024 megabytes
import java.lang.*; import java.math.*; import java.util.*; import java.io.*; public class Main { class Node { int x; int y; public Node(int x,int y){ this.x=x; this.y=y; } public boolean equals(Object o){ Node c=(Node)o; return x==c.x && y==c.y; } public int...
Java
["7\n1 1\n1 2\n2 1\n2 2\n1 2\n1 3\n2 1"]
3.5 seconds
["1 2 4 4 4 6 3"]
null
Java 8
standard input
[ "data structures", "dsu", "divide and conquer" ]
feff009596baf8e2d7f1aac36b2f077e
The first line contains one integer $$$q$$$ ($$$1 \le q \le 3 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ lines follow, each containing two integers $$$x_i$$$, $$$y_i$$$ ($$$1 \le x_i, y_i \le 3 \cdot 10^5$$$), denoting $$$i$$$-th query as follows: if $$$(x_i, y_i) \in S$$$, erase it from $$$S$$$, otherwise in...
2,600
Print $$$q$$$ integers. $$$i$$$-th integer should be equal to the size of $$$E(S)$$$ after processing first $$$i$$$ queries.
standard output
PASSED
6abac3e758a739296f48fff1040d7906
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
//package round_606; import java.util.Scanner; public class SortingRailwayCars { static int n; public static void main(String[] args) { Scanner s = new Scanner(System.in); n = s.nextInt(); int[] loc = new int[n]; for (int i = 0; i < n; i++) { loc[s.nextInt() - 1] = i; } System.out.println(n - mi...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
2a6bbd39fdde11510c7d9f458c4205e5
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
419a130c5610d486a6ae19580c11aade
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.Scanner; //http://codeforces.com/contest/605/problem/A public class Div1605A { int arr[]; int pos[]; int n; public static void main(String []args) { Scanner sc = new Scanner(System.in); Div1605A sol; int n = sc.nextInt(); int temp[] = new int[n+1]; for(int i=1;i<=n;i++) { temp[i]=sc....
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
a6f124ddc8c41fe1a7586b9e498b1b5a
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.Scanner; public class sorting_railway_problem { public static void main(String args[]){ Scanner s= new Scanner (System.in); int n= s.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++){ a[i]=s.nextInt(); } int ans=0; int newa[] = new int[n+1]; for(int i=0;i<n;i++){ newa[a[i]]=new...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
688f230fa53ab1740149aa3b464a0f32
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.*; public class Main { public static void main (String[]args) { int arr[]=new int[100100]; int n; Scanner reader=new Scanner(System.in); n=reader.nextInt (); int x; int ans=0; for (int i=1;i<=n;i++) { x=reader.nextInt (); arr[x]=i; } x=0; int sum=0; for (int i=1;i<=n;i++) { if...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
af9c587a3cab183db86eccf5c2454979
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.*; import java.io.*; public class Q1 { static ArrayList<Integer> adj[]; static char color[]; static TreeSet<Integer> ts[]; static boolean b[],visited[],possible; static Map<Integer,HashSet<Integer>> s; static int totalnodes,colored; static int count[]; static long sum[]; public static void ma...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
90e7c08474920fe1029bb530b6c58eeb
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.File; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class p009 { public static void main(String args[]) throws Exception { StringTokenizer stok = new StringTokenizer(new Scanner(System.in).useDelimiter("\\A").next()); StringBuilder sb = new StringBuilde...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
702102f864f028f9eb99d38059027f1b
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.*; import java.io.*; public class sortlis { static class InputReader { private InputStream stream; private byte[] inbuf = new byte[1024]; private int start= 0; private int end = 0; public InputReader(InputStream stream) { this.stream = stream; ...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
3dcd94fcf8e350a154b57e5d660373ba
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.Map.Entry; import java.util.Scanner; import java.util.TreeMap; public class CF_605A { public static int[] arr; public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); arr = new int[n]; TreeMap<Integer,Integer> tm = new TreeMap<>(); int maxCha...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
8fa113eb8214d96f81a820060a1cfa1e
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class SortingRailwayCars { static int[] arr; public static void main(String[] args) { MyScanner sc = new MyScanner(); int n = sc.nextInt(); arr = new int[n]; for (int i ...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
227801793137cb75862790b1458e839f
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
913c04192709e5a858a78266749312cd
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String ar[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLine()); String s1[]=br.readLine().split(" "); ...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
38eb7b5f4bebc8f946cfb2a8c762997f
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class A { public static void main(String[] args) throws Exception { new A().run(); out.close(); } void run() throws Exception { int ...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
11aa8fc0935f715e18c8e3b62562a08b
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class CF605A { public static void main(String []args) { MyScanner in = new MyScanner(); out = new PrintWrit...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
79861744178ac198ee4abfb9af622761
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
//package codeforces.cfr335div1; import java.io.*; import java.util.StringTokenizer; import java.util.function.Function; /** * Created by raggzy on 4/1/2016. */ public class A { private static class Reader implements Closeable { private BufferedReader br; private StringTokenizer st; pub...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
fba56939f2c93277fcdb8f76c22e151a
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper p...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
e885a36ca168f63d591f861646046e68
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
c716f28fd3dc576061ccfcfe4382fe91
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { FastScanner in; PrintWriter out; static final String FILE = ""; public void solve() { int n = in.nextInt(); ArrayList<Integer> p = readIntList(n); int pos[] = new int[n + 1]; for...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
c0a0142204847ba9351bb9c9f53d1be9
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class A605 { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static int n, cur, max; static int[] a; static StringTokenizer st; public static v...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
edfd6f395f4f3477646ecef580d4a9a6
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; import java.math.*; public class A { 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\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
b65d9982a9dab5ef12ecd6344304b7b0
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class RailwayCars { void solve() { int n = in.nextInt(); int[] A = new int[n]; for (int i = 0; i < n; i...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
664f1daa3fd13f49b9f7127aa03dc3d3
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class SortingRailwayCars605A2 { public static void main(String[] args) throws IOException{ BufferedReader r=new BufferedReader(new InputStreamReader(System.in)); String a=r.readLine(); int b=Integer.parseInt(a); ...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
f830aab026e110a2c26491487e8d7b7c
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.*; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int elm, res = 1; int a[] = new int[100010], cache[] = new int[100010]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); ...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
7b413ab4c1cac3c886b0e4a1d92a26f8
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.Scanner; public class main{ public static void main(String[] args) { int[] a=new int [100005]; int n,q,maxs=-1; Scanner reader=new Scanner(System.in); n=reader.nextInt(); for(int i=0;i<n;i++){ q=reader.nextInt(); a[q]=a[q-1]+1; ...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
75a1f59d1c1a3a5411ff8603a8d3d44a
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.*; import java.io.*; public class Main { static void solve(int test_number, InputReader in, PrintWriter out) { int n = in.nextInt(); int[] pos = new int[n + 1]; for (int i = 0; i < n; i++) { int x = in.nextInt(); pos[x] = i; } if (n ...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
9825d65743f0a5aa020118c377f1ae88
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.lang.*; public class me { public static void main(String[] args) { Scanner br= new Scanner(System.in); int n=br.nextInt(); int a[]=new int[n+1]; for(int i=0;i<n...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
b01ec5b8830bfdcce0cf81a433a24851
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
7bf57cf6b7dd6b7696a79f047fc5b759
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.io.*; import java.util.*; public class R335qB { public static void main(String args[]) { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); int n = in.nextInt(); int p[] = new int[n + 1]; int r[] = new int[n + 1]; for (int i = 1; i <= n; i++){ p[i] ...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
09ba3da758cdd93bf543bc0e0d1390f8
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.ArrayList; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution is at the top */ public ...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
9edf801837ae93f53e8b5a8f9f2b5ffd
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.*; import java.io.*; public class marte{ private int contor=0; public static void main (String args[]) throws Exception{ Scanner input=new Scanner(System.in); HashMap<Integer, Integer> map= new HashMap<Integer, Integer>(); HashMap<String, Integer> map2= new HashMap<String, Integer>(); HashMa...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
4b5239901a8c8f243d3e3c37e0fd518d
train_001.jsonl
1449677100
An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it...
256 megabytes
import java.util.*; import java.io.*; import java.awt.geom.*; import java.math.*; public class CF605A { static final Scanner in = new Scanner(System.in); static final PrintWriter out = new PrintWriter(System.out,false); static void solve() { int n = in.nextInt(); int[] p = new int[n]; int[] pos = new int[n]...
Java
["5\n4 1 2 5 3", "4\n4 1 3 2"]
2 seconds
["2", "2"]
NoteIn the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.
Java 8
standard input
[ "constructive algorithms", "greedy" ]
277948a70c75840445e1826f2b23a897
The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train. The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.
1,600
Print a single integer — the minimum number of actions needed to sort the railway cars.
standard output
PASSED
a1ae1e2941828137202d787de81fa3a6
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
//package com.company; import java.util.*; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); int t =input.nextInt(); for (int i =0;i<t;i++){ int n =input.nextInt(); if (n<2){ System.out.println(-1); ...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
b28ef64dcf34fe01bc68c6e895f9a111
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.*; public class MyClass { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t--!=0) { int n = sc.nextInt(); if(n==1) System.out.println("-1"); else { Sys...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
82140272e38c0ae7b999fe3a18855b92
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.*; public class MyClass { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t--!=0) { int n = sc.nextInt(); if(n==1) System.out.println("-1"); else { cha...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
a72b91543b237f97071c341c67a874f4
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); for(; t >= 1; --t){ int n = scan.nextInt(); if (n == 1) { System.out.println("-1"); cont...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
8dadf6ce0e661c17ec68f51fc269eac3
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); for(; t >= 1; --t){ int n = scan.nextInt(); if (n == 1) { System.out.println("-1"); cont...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
a66d98e93c71f4117e94bd02bcfc2565
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.Scanner; public class BadUgly { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int cases = scan.nextInt(); for (int i = 0; i < cases; i++) { int needed = scan.nextInt(); String x1 = "2"; String x = "3"; ...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
7b55ab655b7b2ce526d6c66b7e26d027
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.PrintWriter; import java.io.InputStreamReader; public class Main { public static void Solve(PrintWriter out,Cin in) { int n = in.nextInt(); if(n == 1) { out.print("-1\n"); } else { String...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
cb12d42b0aba52bf4cec523a0567e75d
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.*; public class HelloWorld{ public static void main(String []args){ Scanner sc = new Scanner (System.in); int test = sc.nextInt(); sc.nextLine(); while(test>0){ int n = sc.nextInt(); if(n==1){ System.out.println(-1); ...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
fb66cb5ceb1c1b92ddfd85bcf6264eaa
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.*; import java.io.IOException; public class Main { public static void main(String[]args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int tcs=Integer.parseInt(br.readLine()); for(int j=0;j<tcs;j++) { ...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
d0cd3e1e1339eddec0a6a6657e771638
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; import java.io.*; impo...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
6f7c766e822a1ba833b6e1d60c992c29
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.*; public class Main { public static void main(String[]args) { Scanner sc=new Scanner( System.in); int t= sc.nextInt(); while(t-->0) { int n=sc.nextInt(); if(n==1) {System.out.println("-1"); } ...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
f08128a04d0f05cd0ec7f89ad2a8be2c
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.*; public class Test { public static void main(String []args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t>0) { int n=sc.nextInt(); if(n==1) { System.out.println(-1); } ...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
b8c22ff635a8868114a5ec9061cdb033
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class p2 { public static void main(String[]args) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); int l=Integer.parseInt(r.readLine()); for(int i=...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
c60f4c2ff8872b286f4561cdba56773e
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static class InputReader { BufferedReader reader; StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } String next() { // reads in the next string while (token...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
b0d2c26ceca1b8f71f481ec3e4764302
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; public class A implements Runnable { public void run() { InputReader sc = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); int t=sc.nextInt(); while(t--!=0) ...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
5168b362038e8df27912b95b4388fa68
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; public class A implements Runnable { public void run() { InputReader sc = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); int t=sc.nextInt(); while(t--!=0) ...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
6be40e15c3c7535771e44a0e7678b801
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.*; public class BadUglyNumbers{ public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t>0) { long n=sc.nextLong(); String s = ""; if(n>1) { s=s+"2"; for(long i=1;i<n;i++) s=s+"3"; System.out.println(s); }...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
6ed87e23312058180c86a3bda65cfa16
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import java.math.*; //Mann Shah [ DAIICT ]. //fast io public class Main { static long mod = (long) (1e9+7); static long mm = (long)(1e9+6); static long N = (long)(2*1e5); static InputReader in; static PrintWriter out; static Debugger deb...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
9100538fa8212a2912226dfe61923397
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { FastReader scan = new FastReader(); int t = scan.nextInt(); boolean[] prime = sieveOfEratosthenes(100000); while(t--> 0) { int n = scan.nextInt(); if(n == 1) System.out.print(-1); else { ...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
63d45024d00783e585b7f28331955a49
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.*; import java.util.*; public class badUglyNums3 { public static void main(String[] args) throws IOException { //get input separately BufferedReader b = new BufferedReader(new InputStreamReader(System.in)); PrintWriter p = new PrintWriter(new BufferedOutputStream(System.out)); StringTokenizer...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
24c1acc1ee773357213fbc5091263284
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.Scanner; public class BadUglyNumbers { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int test = scanner.nextInt(); while (test-- != 0){ int num = scanner.nextInt(); System.out.println(getNum(num)); } }...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
3b9403073fea3974bc1de7b9f728fbf3
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class NextRound { String res; void read() { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); try { int t = Integer.parseInt(bufferedReader.readLi...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
bdadb8317164d7c139e0bfc05ae4e7d8
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
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 { Scanner in = new Scanner(System.in);...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
08bb710cdb6e5b89a9adfb553f1b030c
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
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.*; public class Solution { // Complete the maximumSum function below. static int gcd(int a, int b) { if (a == 0) return b; ...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
4b4e40f44b980f1283f955fedf10dde0
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
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\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
7b07d06c97351f9d95d5ff6c835cdbc1
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.Scanner; public class NewClass2 { public static void main(String args[]) { Scanner scan = new Scanner(System.in); StringBuffer sb = new StringBuffer(); int t = scan.nextInt(); while (t-- > 0) { int n = scan.nextInt(); if (n <= 2) { ...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
e120ae5f9f6bf441b37ba5650c90b244
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.*; import java.util.*; /** * Built using my Brain * Actual solution is at the bottom * * @author Lenard Hoffstader */ public class cfjava { public static void main(String[] args) { OutputStream outputStream = System.out; FastReader in = new FastReader(); PrintWriter out = new Pr...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
a33d44d35bd80a6588b2f7476246486f
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.math.BigInteger; import java.util.*; import java.lang.*; import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class Main{ public static void main(String[] args) { Sca...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
f5f6570aa077bc9a194a3085d1efb69e
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
//package codeforcesa2; import java.util.*; public class BadUglyNumbers { 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(); if(n==1){ System.out.println("-...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
dd1be0da9ab1cbd16598343c7c5452c4
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.Scanner; import java.util.Arrays; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int k=0;k<t;k++) { int n=sc.nextInt(); int result=1; if(n==1) { System.out.println("-1"); contin...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
fbb64d24a9c1235a6d6fb3894ecd864e
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.util.*; import java.io.*; public class Solution{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); if(n == 1){ System.out.println(-1); } e...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
84ed0f7fa6924a7c7b0adc178e5e91f4
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import com.sun.source.tree.Tree; import javax.print.DocFlavor; 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.lang.reflect.Array; import java.math.BigInteger; imp...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
f58069c813b57b0cbc8c05f642825782
train_001.jsonl
1584628500
You are given a integer $$$n$$$ ($$$n &gt; 0$$$). Find any integer $$$s$$$ which satisfies these conditions, or report that there are no such numbers:In the decimal representation of $$$s$$$: $$$s &gt; 0$$$, $$$s$$$ consists of $$$n$$$ digits, no digit in $$$s$$$ equals $$$0$$$, $$$s$$$ is not divisible by any of ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class BadUglyNumber { 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(); String s=""; if(n=...
Java
["4\n1\n2\n3\n4"]
1 second
["-1\n57\n239\n6789"]
NoteIn the first test case, there are no possible solutions for $$$s$$$ consisting of one digit, because any such solution is divisible by itself.For the second test case, the possible solutions are: $$$23$$$, $$$27$$$, $$$29$$$, $$$34$$$, $$$37$$$, $$$38$$$, $$$43$$$, $$$46$$$, $$$47$$$, $$$49$$$, $$$53$$$, $$$54$$$, ...
Java 11
standard input
[ "constructive algorithms", "number theory" ]
43996d7e052aa628a46d03086f9c5436
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 400$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case contains one positive integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). It is guaranteed that the sum o...
1,000
For each test case, print an integer $$$s$$$ which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for $$$s$$$, print any solution.
standard output
PASSED
b922e08369ebf3bc8acabf795bd1149c
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.*; import java.util.*; public class Main { public Main() throws IOException { } static void solve() throws IOException { // String s = input.readLine(); StringBuilder s = new StringBuilder(input.readLine()); int n = s.length(); int minPos[] = new int[n]; // st...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
f97f0c9b4f3e664bd0f53996f8b35587
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { FastReader scr = new FastReader(); OutputStream outputStream = System.out; PrintWriter out = new PrintWriter(outputStream); // int t = scr.nextInt(); // ...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
2996984c677b9b6d3f585a00638fe317
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class C { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String s = reader.readLine(); int size = 0;...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
a74637db57a7e4723c3623afd759bc76
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.util.InputMismatchException; import java.util.Stack; public class D { public static void main(String[] args) { FastScannerD sc = new FastScannerD(System.in); String s = sc.next(); char[] arr = s.toCharArray(); int N = arr.length; char[] ...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
8e98cc7cd136d830be8698b221efc747
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; public class CF { long mod = (long) 1e9 + 7; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br....
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
87eb1daae4c3d6a6886ffe05a3902610
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class SSolution { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); SSolution s = new SSoluti...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
5967793601417b0697e0dbce27aba48c
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
60465454614cdfad1637a851ab6712c7
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Bit...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
1dc251cffb1238f49aa066d81d98542d
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Stack; import java.util.StringTokenizer; public class C2 { static PrintWriter out = new PrintWriter( new Buffere...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
c34552323b35473af62e1333a1c2386b
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.util.Arrays; import java.util.Scanner; import java.util.Stack; public class CandidateCode { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int arr[] = new int[26]; String s = sc.next(); for (int i = 0; i < s.length(); i++) { arr...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
32d52e2dc8227c8ba380d1ed0b9ac143
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.regex.*; public class Myclass { // public static ArrayList a[]=new ArrayList[300001]; public static void main(String[] args) { Inpu...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
8575060c2de8637e8e0c21b5181db427
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.util.*; public class ms { public static void main(String[] args) { Scanner in = new Scanner(System.in); int[] ary = new int[127]; String s = in.nextLine(); for ( int i = 0; i < s.length(); i++ ) { ary[s.charAt(i)]++; } Stack<Character> st = new Stack<>(); StringBuilder sb = new St...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
5139bb173b3740df3078caa2c0b18e21
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; public class Main { private FastScanner in; private PrintWriter out; void solve() throws IOException { String s = in.nextString(); StringBuffer t = new StringBuffer...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
a16e3fb7d115efa785a561e9a1995232
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; public class Main { private FastScanner in; private PrintWriter out; void solve() throws IOException { String s = in.nextString(); StringBuffer t = new StringBuffer(...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
6e683c7af45a7e4d8bc5d4ebe83bd1c1
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.function.*; import java.util.regex.*; import java.util.stream.*; public class Minimal{//PRACTICE18 public static void main(String args[]){ FastScanner sc=new FastScann...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
c436cf659e64a20fd1ea4a1ffb650a49
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outp...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
cd341778f244bfee4a14a3a11777d40a
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.util.*; import java.io.*; import java.text.*; //Solution Credits: Taranpreet Singh public class Main{ //SOLUTION BEGIN void solve(int TC) throws Exception{ String s = n(); TreeMap<Character, Integer> set = new TreeMap<>(); for(int i = 0; i< s.length(); i++){ set....
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
b1e340375c0d214b8012f2b44c80da9f
train_001.jsonl
1492266900
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: Extract the first character of s and append t with this character. Extract the last character of t and append u with this characte...
256 megabytes
import java.util.*; public class ms{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); int[] arr = new int[26]; for(int i=0;i<s.length();i++){ arr[s.charAt(i)-'a']++; } String res=""; Stack<Character> st = new Stack<Character>(); StringBuilder sb = n...
Java
["cab", "acdb"]
1 second
["abc", "abdc"]
null
Java 8
standard input
[ "data structures", "greedy", "strings" ]
e758ae072b8aed53038e4593a720276d
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
1,700
Print resulting string u.
standard output
PASSED
9c15ffda338c3e9c37ba19f4fd660a75
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
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.List; import java.util.StringTokenizer; public class TaskD { public static void main(String[] ar...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
3f3aeb5babbac0891a8a7a8123764601
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
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.List; import java.util.StringTokenizer; public class TaskD { public static void main(String[] ar...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
f60396288019f1d7240a82f77852c6f9
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelp...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
aab754402194820ef771c52523b9e9bc
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String[] cmd=br.readLine().split(" "); int n=Integer.valueOf(cmd[0]); long[] arr=new l...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
fa3fe33e0b99c63fd84e54030e03cfd1
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { InputStreamReader in = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(in); int n = Integer.parseInt(br.readLine()); StringTokenizer st = new StringTokenize...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
670b7446ec1833cce55588adae98fe0c
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
256 megabytes
import java.util.*; import java.io.*; public class Main implements Runnable{ FastScanner sc; PrintWriter pw; final class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { try { br = new BufferedReader(new InputStreamReader(Syste...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
eb43f808f2032013592810968ddab451
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
256 megabytes
import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.Comparator; public class scratch_25 { static class Reader { static BufferedReader reader; static StringTokenizer tokenizer; /** * call this method to initialize reader ...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
d53349abe74b5530f6482fb83a62735f
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
256 megabytes
// package Quarantine; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class OmkarAndCircle { public static void main(String[] args)throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.i...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
553d5f8bcb88cc04da7ce204b2b71a5b
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class D { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader file = new BufferedReader(new InputStreamReader(System.in)); int n = In...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
c6ef392dcfa1f8ec8c996c0542318014
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.InputMismatchException; import java.util.*; import java.io.*; import java.lang.*; public class Main{ public static class InputReader { private InputStream stream; ...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
6c92c9525abb16d9ad88d9703460bef6
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
256 megabytes
import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; public class Solution { public static class FastReader { BufferedReader br; StringTokenizer root; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String nex...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
0cc81e75a546b955a98c6b0f51087f2d
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
256 megabytes
//package learning; import java.util.*; import java.io.*; import java.lang.*; import java.text.*; import java.math.*; import java.util.regex.*; public class NitsLocal { static ArrayList<String> s1; static boolean[] prime; static int n = 200001; static void sieve() { Arrays.fill(prime , true); prim...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
f2457741196d2eefb3ea7dbfd477e527
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
256 megabytes
import java.util.*; public class OMKARISSOHOT{ public static void main(String[] args) { Scanner omkar = new Scanner(System.in); long[] arr = new long[omkar.nextInt()]; if(arr.length == 1) { System.out.println(omkar.nextLong()); return; } for(int i = 0; i < arr.length; i++) { arr[...
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output
PASSED
e89f38effde3c98d45bf31cda5a5b5e3
train_001.jsonl
1594479900
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given $$$n$$$ nonnegative integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle, where $$$n$$$ must be odd (ie. $$$n-1$$$ is divisible by $$$2$$$). Formally, for all $$$i$$$ such that $$$2...
256 megabytes
import java.io.*; public class OmkarLastCircle { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t=1; while(t-->0) { int n=Integer.parseInt(br.readLine()); String str[]=br.readLine()....
Java
["3\n7 10 2", "1\n4"]
2 seconds
["17", "4"]
NoteFor the first test case, here's how a circular value of $$$17$$$ is obtained:Pick the number at index $$$3$$$. The sum of adjacent elements equals $$$17$$$. Delete $$$7$$$ and $$$10$$$ from the circle and replace $$$2$$$ with $$$17$$$.Note that the answer may not fit in a $$$32$$$-bit integer.
Java 8
standard input
[ "dp", "greedy", "games", "brute force" ]
a9473e6ec81c10c4f88973ac2d60ad04
The first line contains one odd integer $$$n$$$ ($$$1 \leq n &lt; 2 \cdot 10^5$$$, $$$n$$$ is odd)  — the initial size of the circle. The second line contains $$$n$$$ integers $$$a_{1},a_{2},\dots,a_{n}$$$ ($$$0 \leq a_{i} \leq 10^9$$$)  — the initial numbers in the circle.
2,100
Output the maximum possible circular value after applying some sequence of operations to the given circle.
standard output