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
0e2a453562d14d409afcd1cb89d66724
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
//some updates in import stuff import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; //key points learned //max space ever that could be alloted in a program to pass in cf //int[][] prefixSum = new int[...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
27b85033f59de80dc3ad25aae5225333
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
import java.io.*; import java.util.*; public class a{ public static FastScanner fs; public static BIT tree; public static char[][]grid; public static void main(String args[]) { fs=new FastScanner(); int n=fs.nextInt(); int m=fs.nextInt(); int q=fs.nextInt()...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
e6ac36d9775b2617a06e8e9f5b6e8ef1
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
import java.io.*; import java.lang.Math; import java.lang.reflect.Array; import java.util.*; import javax.swing.text.DefaultStyledDocument.ElementSpec; public final class Solution { static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) ); static BufferedWriter bw = new B...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
167208027ac9eb75f7440499330e043b
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
import java.util.*; import java.io.*; public class F { static class Scan { private byte[] buf=new byte[1024]; private int index; private InputStream in; private int total; public Scan() { in=System.in; } public int scan()throws ...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
6350cd8bf62429424c35b553cc7dc0f4
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class F1674 { public static void main(String[] args) { InputStream inputStream = System....
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
9988e15d0faea7b5a0b50ccd217d81e7
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static Scanner sc = new Scanner(System.in); public static PrintWriter pw = new PrintWriter(System.out); public static void main(String[] args) { solve(); pw.flush(); } st...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
861fd41ecfb3588371361d5ed058634b
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
// JAI SHREE RAM, HAR HAR MAHADEV, HARE KRISHNA import java.util.*; import java.util.Map.Entry; import java.util.stream.*; import java.lang.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.io.*; public class CodeForces { static private final String INPUT = "input.txt"; s...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
c4d3e7fb84c819c047f36ab26c3b3d4b
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
// JAI SHREE RAM, HAR HAR MAHADEV, HARE KRISHNA import java.util.*; import java.util.Map.Entry; import java.util.stream.*; import java.lang.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.io.*; public class CodeForces { static private final String INPUT = "input.txt"; s...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
9fdd278dd56f455f0fe4d7b6d17df69c
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
import java.io.*; import java.util.*; public class CodeForces { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int[] nmq = Arrays.stream(in.readLine().split("\\s+")).mapToInt(Integer::parseInt).toArray(); ...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
e97c803afff1849914121299b63864b9
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
// package c1674; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.lang.invoke.MethodHandles; import java.util.Random; import java.util.StringTokenizer; // // Codeforces Round #786 (Div. 3) 2022-05-02 07:35 // F. Desktop Rearrangement //...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
2c803799036876c2e36b03eba6aeb901
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class codeforces_786_F { private static void solve(FastIOAdapter in, PrintWriter out) { int n = in.nextInt(); int m = in.nextInt(); int q = in.nextInt(); int[] fr...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
e26ea4fddcc3ecaed4cacc63c0005174
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
import java.util.*; public class F { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { // TODO Auto-generated method stub solve(0); } private static void solve(int t) { int m = sc.nextInt(); int n = sc.nextInt(); int q = sc.nextInt(); sc.nextLine();...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
b5dd5338c1279ac9d0fc62216b368d80
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
import java.io.*; import java.util.*; public class q6 { public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // public static long mod = 1000000007; static int[] farr; public static void update(int idx,int val){ while(idx < farr.length){ ...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
aee5d1bc901b2e1746bb9bf69e5b68be
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
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 { static int sum(int idx , int bit[]) { int ans = 0; while(idx > 0) { ans...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
f81877f1dc410681aa36b60945d64990
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); String s[]=bu.readLine().split(" "); i...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
769301f209dcacac018605fedf52ebfd
train_107.jsonl
1651502100
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n \times m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon).The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
256 megabytes
import java.io.*; import java.util.*; public class CF1674F extends PrintWriter { CF1674F() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1674F o = new CF1674F(); o.main(); o.flush(); } int[] ft; void update(int i, int n, int x) { while (i < n) { ft[i]...
Java
["4 4 8\n..**\n.*..\n*...\n...*\n1 3\n2 3\n3 1\n2 3\n3 4\n4 3\n2 3\n2 2", "2 5 5\n*...*\n*****\n1 3\n2 2\n1 3\n1 5\n2 3"]
3 seconds
["3\n4\n4\n3\n4\n5\n5\n5", "2\n3\n3\n3\n2"]
null
Java 11
standard input
[ "data structures", "greedy", "implementation" ]
9afb205f542c0d8ba4f7fa03faa617ae
The first line of the input contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \le n, m \le 1000; 1 \le q \le 2 \cdot 10^5$$$) — the number of rows in the desktop, the number of columns in the desktop and the number of queries, respectively. The next $$$n$$$ lines contain the description of the desktop. The $$$...
1,800
Print $$$q$$$ integers. The $$$i$$$-th of them should be the minimum number of moves required to make the desktop good after applying the first $$$i$$$ queries.
standard output
PASSED
34b2b386e2c669ba49d4520239e5c97d
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.util.*; import java.util.concurrent.TimeUnit; import java.io.*; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; public class G_Remove_Directed_Edges{ public static void solve(){ } public static void main(String args[])throws IOException...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
3e53ae52dc378e1c3f2d96e3f8bf3cec
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.text.DecimalFormat; import java.util.*; public class Codeforces { static long mod= 10000_0000_7; static int dp[]; static int fake[]; static int in[]; static List...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
6d2e2e460d2c369609c2e3ef14d6d451
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
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.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Priorit...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
8c4410758425904894f0629f551940f1
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
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.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Priorit...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
4e0a3369e2371884222c5dc9c6b64dc6
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.*; import java.util.*; public class RemoveDirectedEdges { public static void solve(FastIO io) { final int N = io.nextInt(); final int M = io.nextInt(); Node[] nodes = new Node[N + 1]; for (int i = 1; i <= N; ++i) { nodes[i] = new Node(i); } for (int i = 0; i < M; ++i) ...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
e566121574e5dfc07d40aaf6346d67c9
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class RemoveDirectedEdges { public static void solve(FastIO io) { final int N = io.nextInt(); final int M = io.nextInt(); Node[] nodes = new Node[N + 1]; for (int i = 1; i <= N; ++i) { nodes[i] = new Node(i); } for (in...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
ee80384bcf8eb5e8336a764a43ab7d9d
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.util.*; import java.io.*; public class Main { static long startTime = System.currentTimeMillis(); // for global initializations and methods starts here static List<List<Integer>> graph; static List<Integer> ordered; static boolean[] visitedBy; static void initialize...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
dae8c56d325a5ee708f57c2a4b631b14
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.util.*; import java.io.*; public class Main { static long startTime = System.currentTimeMillis(); // for global initializations and methods starts here static List<List<Integer>> graph; static List<Integer> ordered; static boolean[] visitedBy; static void initialize...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
903814b76eec364b75dc64cb0fa0e28a
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.util.*; import java.io.*; import java.lang.reflect.Array; public class tr0 { static PrintWriter out; static StringBuilder sb; static long mod = (long) 1e9 + 7; static long inf = (long) 1e16; static int n, m; static ArrayList<Integer>[] ad, ad1; static int[][] remove, add; static long[...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
4b2f7f4b5d19e3f8b08d770f3eb86d0c
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; import java.util.Scanner; public class G { public static void main(String[] args) { new G().solve(); } public void solve() { Scanner scanner = new Scanner(System.in); int t = 1; while (t-...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
3e7d4160f8709c24a4f8c38e431c2cd0
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class div3_1674_g { public static void main(String[] args) { ...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
358fcbdb3ad0f688b92cdea1e0902c50
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class Main { static int n, m, res; static int ans[], in[]; static ArrayList<Integer> g[]; static void dfs(int u) { int s = 0; for (int v...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
0e272f92a64bfc4da7a46f0a9e67cb85
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static Main2 admin = new Main2(); public static void main(String[] args) { admin.start(); } } class Main2 { //---------------------------------INPUT READER-----------------------------------------// public BufferedRead...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
2da49863ecfea849a06d8b9c9fddaa1a
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.*; import java.util.*; public class G_Remove_Directed_Edges { public static int[] dp, outd, ind; public static void main(String[] args) { FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); // try { // out = new PrintWri...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
ea9fc6a4e1bbb19f5797a1bd5b6ebadb
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.*; import java.util.*; public class Main { static Main2 admin = new Main2(); public static void main(String[] args) { admin.start(); } } class Main2 { //---------------------------------INPUT READER-----------------------------------------// public BufferedRead...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
cf1f2e794fe2d3161c481dbd473c4885
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.util.*; public class ACM { private static int INF = (int) 1e9; private static int n; private static int[] in, out; private static ArrayList<Integer>[] graph; private static int[] dp; public static void main(String[] args) { Scanner sc = new Scanner(System.in); ...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
aa532575fbe9950b21940beb799d9968
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.util.*; public class RemoveDirectedEdge { static ArrayList<Integer> in = new ArrayList<Integer>(); static ArrayList<Integer> out = new ArrayList<Integer>(); static ArrayList<Integer> dp = new ArrayList<Integer>(); static ArrayList<ArrayList<Integer>> graph = new ArrayList<ArrayList<In...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
91d1f6fde6ada70c4cbbd20666a6176d
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.util.*; import java.io.*; // res.append("Case #"+(p+1)+": "+hh+" \n"); ////*************************************************************************** /* public class E_Gardener_and_Tree implements Runnable{ public static void main(String[] args) throws Exception { new Thr...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
49d149bb3763c24430e09c6033408b85
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
/* I am dead inside Do you like NCT, sKz, BTS? 5 4 3 2 1 Moonwalk Imma knock it down like domino Is this what you want? Is this what you want? Let's ttalkbocky about that */ import static java.lang.Math.*; import java.util.*; import java.io.*; public class x1674G { static final int INF = Integer.MIN...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
f3cf4b2fc9b094b9d1c046d5315ac28e
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.*; import java.util.*; public class Main{ static LinkedList<Integer>[]adj; static int[]memo; static int[]in,out; static int dp(int i){ if(memo[i]!=-1)return memo[i]; int ans=1; if(out[i]>=2) { for (int j : adj[i]) { if(in[j]...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 8
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
53bc669b6bacc8cbd899ff11a5ed6380
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.System.out; import java.util.*; import java.io.*; import java.math.*; /* getOrDefault valueOf char[] arr=st.nextToken().toCharArray(); System.out.println(); List<Integer> l...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 17
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
69a1ce0870d9bd972ee90c8fb94a0a93
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.System.out; import java.util.*; import java.io.*; import java.math.*; /* getOrDefault valueOf char[] arr=st.nextToken().toCharArray(); System.out.println(); List<Integer> l...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 17
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
e9b7cd11e6f03c981990a930fb6339e1
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static AReader scan = new AReader(); static int N = 200010; static int[] h = new int[N]; static int[] e = new int[N]; static in...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 11
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
040b5c6b95131f9620166cadc633ea30
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.security.cert.X509CRL; import java.util.*; import java.lang.*; import java.util.stream.Collector; import java.util.stream.Co...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 11
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
5eb0606e80453ef36f2b0f9a419bf81e
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import jav...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 11
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
610e7684e93cc8b856b8ac896c373c44
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
// package c1674; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.lang.invoke.MethodHandles; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Queue; import jav...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 11
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
bb87461ef237c7a681f3dcb2f8b7bd6f
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
//Utilities import java.io.*; import java.util.*; public class a { static int n, m; static int[] ord; static int idxOrd; static boolean[] vis; static ArrayList<Integer>[] adj, revAdj; static int u, v; static int[] dp; static int res = 0; public static void main(String[] args) throws IOExceptio...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 11
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
ff778db9b306e7834f08c8bc1ccb6d29
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.*; import java.util.*; public class G { void go() { int ans = 0; int n = Reader.nextInt(); int m = Reader.nextInt(); List<Integer>[] g = new List[n + 1]; List<Integer>[] rg = new List[n + 1]; int[] ind = new int[n + 1]; List<Intege...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 11
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
0e3591bb12548fa2d525a18a2fa085a3
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); String s[]=bu.readLine().split(" "); i...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 11
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
01d94624829dbad5dd84fb0d7500b947
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.util.*; import java.io.*; // you can compare with output.txt and expected out public class Round786G { MyPrintWriter out; MyScanner in; final static String IMPOSSIBLE = "IMPOSSIBLE"; final static String POSSIBLE = "POSSIBLE"; final static String YES = "YES"; final static String NO = "NO"...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 11
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
4a969cebb2405c49d65d1f0c9265253b
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.*; import java.util.*; public class a{ public static FastScanner fs; public static int n,m,indeg[]; public static ArrayList<Integer>g[],rg[]; public static void main(String args[]) { fs=new FastScanner(); n=fs.nextInt(); m=fs.nextInt(); indeg...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 11
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
2f60c26857cc5051e25b06fa5d62d54d
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class JavaTest { private static PrintWriter out = new PrintWriter(System.out); private static Scanner sc; public static void main(String args[]) throws Exception {...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 11
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
838c986aa32410fbf78904cecad5524d
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.util.*; public class G { static Scanner sc = new Scanner(System.in); static List<Integer> [] graph; static int [] toCount; static int [][] memo; public static void main(String[] args) { // TODO Auto-generated method stub solve(0); } private static void solve(int t) { int n =...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 11
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
aaa80b17f185c28a96199c46a984886e
train_107.jsonl
1651502100
You are given a directed acyclic graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. The vertices are numbered from $$$1$$$ to $$$n$$$. There are no multiple edges and self-loops.Let $$$\mathit{in}_v$$$ be the number of incoming edges (indegree) and $$$\mathit{out}_v$$$ be the number of outgoing edges (outdegree) ...
256 megabytes
import java.io.*; import java.util.*; public class CF1674G extends PrintWriter { CF1674G() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1674G o = new CF1674G(); o.main(); o.flush(); } int[] dp, eo, fo; int[][] ej; void append(int i, int j) { int o...
Java
["3 3\n1 2\n2 3\n1 3", "5 0", "7 8\n7 1\n1 3\n6 2\n2 3\n7 2\n2 4\n7 3\n6 3"]
2 seconds
["2", "1", "3"]
NoteIn the first example, you can remove edges $$$(1, 2)$$$ and $$$(2, 3)$$$. $$$\mathit{in} = [0, 1, 2]$$$, $$$\mathit{out} = [2, 1, 0]$$$. $$$\mathit{in'} = [0, 0, 1]$$$, $$$\mathit{out'} = [1, 0, 0]$$$. You can see that for all $$$v$$$ the conditions hold. The maximum cute set $$$S$$$ is formed by vertices $$$1$$$ a...
Java 11
standard input
[ "dfs and similar", "dp", "graphs" ]
2d3af7ca9bf074d03408d5ade3ddd14c
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$0 \le m \le 2 \cdot 10^5$$$) — the number of vertices and the number of edges of the graph. Each of the next $$$m$$$ lines contains two integers $$$v$$$ and $$$u$$$ ($$$1 \le v, u \le n$$$; $$$v \neq u$$$) — the description of ...
2,000
Print a single integer — the maximum possible size of a cute set $$$S$$$ after you remove some edges from the graph and both indegrees and outdegrees of all vertices either decrease or remain equal to $$$0$$$.
standard output
PASSED
e9d0e5043c94035d911b9abb922aed46
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.util.*; /** * * @author eslam */ public class IceCave { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } Stri...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
9cb9ffb6a2f9327345564cc07e9763d1
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.lang.*; import java.util.*; public class ComdeFormces { public static int cc2; public static pair pr; public static long sum; public static int ind2; public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub // Reader.init(System.in); ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
842780a5821e2c444960837259f85f10
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Solution { static long[] fac; public static void main(String[] args) throws IOException { Reader.init(System.in); BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out)); /* // Do n...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
5505393b180bc3358a5cce54a3f6a579
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String[] args) throws IOException { int n = sc.nextInt(); int[] arr = sc.nextIntArray(n); long[] temp = new long[n]; temp[0] = Math.max((long) Math.ceil(arr[0] / 2.0), arr[1]); temp[n - 1] = Math...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
18e7912af19baa315a86dbca99b9b389
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; import java.io.*; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.math.BigInteger; public final class Main{ static class Reader { ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
50cc907c8606780b62333e4f2fc048ca
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.security.cert.X509CRL; import java.util.*; import java.lang.*; import java.util.stream.Collector; import java.util.stream.Co...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
9c4832a11f12a0aae8605550a760f581
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
// JAI SHREE RAM, HAR HAR MAHADEV, HARE KRISHNA import java.util.*; import java.util.Map.Entry; import java.util.stream.*; import java.lang.*; import java.math.BigInteger; import java.text.DecimalFormat; import java.io.*; public class CodeForces { static private final String INPUT = "input.txt"; s...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
bbbfa738525290a1ff1649f5877feac7
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; public class temp { class Pair{ int i; int j; Pair(int i,int j){ this.i = i; this.j = j; } } public static void main(String [] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
3f4b67e322ab1b1b4ed8401e948f9c9e
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException{ FastReader fr=new FastReader(); PrintWriter pw=new PrintWriter(System.out); int n=fr.nextInt(); int [] arr=new int[n]; int a=1000001,b=1000001; ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
6b9d3c47bcc082ef0130821fadf5f3e4
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; public class E { static Scanner sc = new Scanner(System.in); static TreeMap<Integer, Integer> map; static StringBuilder sb; public static void main(String[] args) { // TODO Auto-generated method stub sb = new StringBuilder(); solve(0); System.out.println(sb); } priv...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
974ec316aacd028c54e7f76887a41d3a
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.util.*; public class Main { static long nod(long a, long b) { while (Math.min(a, b) != 0) { if (a > b) { a = a % b; } else b = b % a; } return a + b; } public static void main(String[] args) throws I...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
ce23af8b42c1c0e88880b56ef359af54
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; public class problem{ public static int answer(int x,int y){ int total = 0; while(x>0 || y>0){ if(x>y){ x = x - 2; y = y-1; }else{ y = y-2; x = x-1; } tot...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
e9a07c98950135675cf4639889a9b540
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; import java.io.*; // you can compare with output.txt and expected out public class Round786E { MyPrintWriter out; MyScanner in; final static String IMPOSSIBLE = "IMPOSSIBLE"; final static String POSSIBLE = "POSSIBLE"; final static String YES = "YES"; final static String NO = "NO"...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
819695371193a87a36aaa06314620eff
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class BreakingTheWall { public static void main(String args[]) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // int t = Integer....
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
5c5decc3bc5ce5d5657a4626aa7b87c3
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class E_Breaking_the_Wall { public static void main(String[] args) { FastReader rd = new FastReader(); // StringBuilder bd = new StringBuilder(); int n = rd.nextI...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
9921c9ee949836d7183d55f2ba738533
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.util.*; import java.util.concurrent.ThreadLocalRandom; public class E { //java -Xss515m Solution.java < input.txt private static final String SPACE = "\\s+"; private static final int MOD = 1_000_000_007; private static final Reader in = new Reader(); publi...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
a992b0ef8f699256a1c098fb3a5dac50
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class E { // 注意不要用Arrays.sort() // 注意Math.pow可能导致精度问题 // 注意int溢出问题 static class Task { public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.nextInt(); ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
48314689631738a02fff042ee9f17e8d
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int [] wall = new int[n]; for (int i = 0; i < n; i++) { wall[i]=scanner.n...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
f322c85901bf57f04baf9525b0146f2c
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.StreamTokenizer; import java.math.BigInteger; import static java.lang.System.out; import static java.lang.Math.*; import java.util.*; public class Main { static public ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
7a420d6988f1338af2a0b084d3291e3c
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.text.DecimalFormat; import java.util.*; public class Main { static class Pair { long a,b,c; public Pair(long a,long b,long c) { this.a=a; this.b=b; this.c=c; } // @Override // public ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
22ef29d8828938dcf271ef6fe7175292
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
/*----------- ---------------* Author : Ryan Ranaut __Hope is a big word, never lose it__ ------------- --------------*/ import java.io.*; import java.util.*; public class Codeforces2 { static PrintWriter out ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
9be7268749db4f5b1dd308fd1f182ef4
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; import java.io.*; public class Main { static StringBuilder sb; static dsu dsu; static long fact[]; static int mod = (int) (1e9 + 7); static long get(int a,int b){ if(b>a){ int temp=a; a=b; b=temp; } long diff=a-b; ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
c24b66693e8cc41642de89bbe39d950e
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.Writer; import java.io.OutputStreamW...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
1abb8da06be78215a01383006d0b2790
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Scanner; public class E { public static void main(String[] args) { Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); PrintWriter out = new PrintWriter(...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
829974acb55695d704902ceab286d754
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
//Utilities import java.io.*; import java.util.*; public class a { static int n; static int[] a, b; static int res = Integer.MAX_VALUE; public static void main(String[] args) throws IOException { n = in.iscan(); a = new int[n]; b = new int[n]; for (int i = 0; i < n; i++) { a[i] = in.iscan(); ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
43609e269b88afd89f3b6cb5c86326dc
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
//some updates in import stuff import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; //key points learned //max space ever that could be alloted in a program to pass in cf //int[][] prefixSum = new int[...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
cc4a0aaeed4f63c0fe469ee0f16f8e30
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.util.*; public class E1 { public static void main (String[] args) throws IOException { Kattio io = new Kattio(); int n = io.nextInt(); long[] arr = new long[n]; for (int i=0; i<n; i++) { arr[i] = io.nextLong(); } //case 1: long min1 = Integer.MAX_VALUE; long min2 = In...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
3a51d5b325b95e224077b18d3185f9ed
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.lang.Math; import java.lang.reflect.Array; import java.util.*; import javax.swing.text.DefaultStyledDocument.ElementSpec; public final class Solution { static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) ); static BufferedWriter bw = new B...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
3b431b5382bbe0e41e364e547928943b
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.lang.reflect.Array; import java.util.*; import java.util.stream.IntStream; import java.util.stream.Stream; public class Main { public static void main(String[] args) { in = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); try { // ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
75fa85f40ef2f2b7378248eb861ce097
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[n]; int b[]=new int[n]; for(int i=0;i<a.length;i++){ a[i]=sc.nextInt(); ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
6c0db65131301121f297d565ee38ef0e
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.util.*; public class E { private int min2(int a, int b) { int max = Math.max(a, b); int min = Math.min(a, b); if((max + 1) / 2 >= min) { return (max + 1) / 2; } else { return (max + min + 2) / 3; } } ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
92e3bf63d10ec1dc994b78a44c7d74e5
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Stack; public class Main { static long MOD = 998244353l; int min = Integer.MAX_VALUE; int max = 0; char result[][]; int count = 0; int pattern = 0; public static void main(Stri...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
4f7f14918a709f314ea6869b73659f55
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; import java.lang.*; public class X { public boolean[] V; public ArrayList<ArrayList<Integer>> E; public int S; public boolean[] P; public int Curr; public HashSet<Integer> Tot; public HashSet<Integer> Child; public ArrayList<ArrayList<Integer>> RevE; public int[] Rev; public...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
096d1613cc5ac7bbe20bb71e0520861b
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.Collections; import java.util.StringTokenizer; public class E implements Runnable { public static void main(String[] args) { new Thread(null, new E(), "whatever", 1 << 26).start(); } FastScanner s = new FastScanner(System.in); ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
bb71ec36528cb362cf630f09a07ccf10
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.text.DecimalFormat; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class Solution { public static void main(String[] args) { ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
41738afec9b1a0e5f269ccda8c07be59
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
/* "Everything in the universe is balanced. Every disappointment you face in life will be balanced by something good for you! Keep going, never give up." Just have Patience + 1... */ import javax.swing.plaf.basic.BasicInte...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
74c95e6ad838faeb744358ba37538d34
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.util.*; public class Codeforces { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); int n=Integer.parseInt(bu.readLine()); ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
e3737846fac78c0eb9429b86c76c3dfd
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; import java.io.*; public class Main extends PrintWriter { Main() { super(System.out); } static boolean cases = false; // Solution void solve(int t) { int n = sc.nextInt(); int a[] = sc.readIntArray(n); int b[] = a.clone(); sort(b); ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
ac7be6c1dd6f2a2ec8f454ec4ad59bca
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.StringTokenizer; public class E { public static void main(String[] args) throws IOException { BufferedReader input = new Buffere...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
fb684d17996dc9843fda50a4704a726c
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; public class Main { public static FastReader cin; public static PrintWriter out; /*static int []arr=new int [5005]; static int []he=new int[5005]; static int []e=new int [100005]; static int []ne=new int [100005]; ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
b57c271a2ec2b7c7b1661d254635b992
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; public class MyClass { public static int formula(int a,int b){ int n=a-b; if(a-n*2<0){return (a+1)/2;} float v = 2*b - a; return a-b+(int)Math.ceil(2*v/3); } public static int compute(int[] a){ int n = a.length; int dp=0; ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
13cd81459c9803020eaec0d4fadc535e
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; public class MyClass { public static int formula(int a,int b){ int n=a-b; if(a-n*2<0){return (a+1)/2;} float v = 2*b - a; return a-b+(int)Math.ceil(2*v/3); } public static int compute(int[] a){ int n = a.length; int [] dp = new ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
3c5f82c98dabb25a88be734ee3cf94d0
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
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 CF786_E { public static void main (String[] args) throws java.lang.Exception { /* BufferedReader br=new B...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
6199c33403b199bde6f358719a24044f
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.*; import java.util.*; public class CF1674E extends PrintWriter { CF1674E() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1674E o = new CF1674E(); o.main(); o.flush(); } static final int INF = 0x3f3f3f3f; void main() { in...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
d6723a950c0a95ce26cbb0135caa7e14
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
/* package codechef; // don't place package name! */ //package com.company; import java.util.*; import java.io.*; import java.lang.*; public class Main{ static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
2209a06b8a81afb7aedd7f95d1a1175c
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; public class App{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; for(int i = 0; i < n ; i++){ arr[i] = sc.nextInt(); } int res = Intege...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
865cffa35e191ec550d64f2ff2a6b054
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; import java.io.*; public class E { static class Scan { private byte[] buf=new byte[1024]; private int index; private InputStream in; private int total; public Scan() { in=System.in; } public int scan()throws ...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
f961cb9a1467f5620bfd746799ca1bf0
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
// package c1674; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.lang.invoke.MethodHandles; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; // // Codeforces Round #786 (Div. 3) 2022-05-02 07:35 // E....
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
cf5b99eaa130db42c0837e3b5ff3a8de
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Solution { static Reader input = new Reader(); public static void main(String[] args) throws IOException { int n = input.nextInt(); int[] a = new in...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output
PASSED
f98508b290e8eb2dd5a28b5474c0bc40
train_107.jsonl
1651502100
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th section...
256 megabytes
import java.util.*; import java.io.*; public class Linova { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int n = Integer.parseInt(f.readLine()); StringTokenizer st = new Stri...
Java
["5\n20 10 30 10 20", "3\n1 8 1", "6\n7 6 6 8 5 8", "6\n14 3 8 10 15 4", "4\n1 100 100 1", "3\n40 10 10"]
2 seconds
["10", "1", "4", "4", "2", "7"]
NoteIn the first example, it is possible to break the $$$2$$$-nd and the $$$4$$$-th section in $$$10$$$ shots, for example, by shooting the third section $$$10$$$ times. After that, the durabilities become $$$[20, 0, 10, 0, 20]$$$. Another way of doing it is firing $$$5$$$ shots at the $$$2$$$-nd section, and another $...
Java 11
standard input
[ "binary search", "brute force", "constructive algorithms", "greedy", "math" ]
f4a7c573ca0c129f241b415577a76ac2
The first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of sections. The second line contains the sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th section.
2,000
Print one integer — the minimum number of onager shots needed to break at least two sections of the wall.
standard output