Skip to main content
Dani is writing some arrays in her favorite text editor NOTES. Each line of the document describes an array in the following format:
Here  is the array's number of elements and  are its contents.
Dani wrote  arrays in the file and left for lunch. To her dismay, her little brother Nik deleted all the newline characters from the file while she was gone! For example, consider the file in the table below:
image
Given the contents of Dani's NOTES file with all the newlines removed, find the value of  (i.e., the number of arrays in the initial file).
Input Format
The first line contains an integer denoting  (the number of integers in the file).
The second line contains  space-separated integers describing each respective value in the file.
Constraints
Output Format
Print a single integer denoting .
Sample Input 0
11
5 4 5 4 3 3 2 1 4 1 4
Sample Output 0
3
Explanation 0
The file looks like this after removing all the newlines:
image
After re-adding the newlines where they belong in the file, it looks like this:
image
Because there are three arrays declared in the reconstructed file, we print  as our answer.

Comments

Popular Posts

Dijkstra's algorithm

Djikstra's algorithm   solves the problem of finding the shortest path from a point in a graph (the  source ) to a destination. It turns out that one can find the shortest paths from a given source to  all  points in a graph in the same time, hence this problem is sometimes called the  single-source shortest paths  problem. This problem is related to the spanning tree one. The graph representing all the paths from one vertex to all the others must be a spanning tree - it must include all vertices. There will also be no cycles as a cycle would define more than one path from the selected vertex to at least one other vertex. For a graph, G = (V,E) where V is a set of vertices and E is a set of edges. Dijkstra's algorithm keeps two sets of vertices: S    the set of vertices whose shortest paths from the source have already been determined  and V-    S :   the remaining v...

Adaptive Software Development (ASD)

Adaptive Software Development (ASD) :- Adaptive Software Development(ASD) has been proposed by Jim High smith as technique for building complex software and system. ASD focus on human collaboration and team self-organization. Jim High smith defines an ASD "Life Cycle" that consist of three phases  Speculation Collaboration learning  During speculation, the project is initiated and adaptive cycle planning is conducted. Adaptive cycle planning uses project Initiation information,the customer's mission statement ,basic requirements and project constraint to define the set of release cycles that will be required for the project. Collaboration encompasses communication and team-work but it also enphasizes individualism because individual creativity plays an important role in collaborative thinking.It is all above all,a matter of trust. people working together must trust one another to comment without war help without irritation work as hard as ...

Binary Tree

Given a Binary Tree, convert it into its mirror. What is a Binary Tree? ➤A binary tree is made of nodes, where each node contains a "left" reference, a "right" reference, and a data element. The topmost node in the tree is called the root . Every node (excluding a  root ) in a tree is connected by a directed edge from exactly one other node. This node is called a parent.              Input: ➤The task is to complete the method that takes one argument, root of Binary Tree and modifies the tree. Output:   ➤The function should convert the tree to its mirror. Plus:  Check whether the binary tree and mirror tree is same or not. FOLLOW ME ON  :- INSTAGRAM  :-  https://www.instagram.com/akshay_methaniya_2809/ YOUTUBE :-  https://www.youtube.com/channel/UCDbGAU0c_78ue2IXi6ibtYQ FACEBOOK :-  https://www.facebook.com/akshay.methaniya