Good impression of programmers in the 10th Beijing Information Science and Technology University Programming Competition and ACM Selection Competition in 2018

Link: https://www.nowcoder.com/acm/contest/118/H
Source: Niuke.com

Topic description


There is a programmer who has done n projects and he wants to change jobs, so he wants to make a good impression on the interviewer. So he wanted to make himself look promising and correspondingly competitive, so he decided to select several projects from the N successful or failed projects he had done before without changing the original chronological order, so that he could show Any successful project that comes out will not be followed by a failed project. In this way, he can show his full potential: although he will fail at the beginning of the project, once he learns, he will not fail again. Specifically, given a "01" sequence with n numbers, such as a "01" sequence with 5 numbers: 0 0 0 0 1, where 0 represents a failed project and 1 represents a successful project. i.e. the first 0 represents the first failed project, the second 0 represents the second failed project... and the last 1 represents the fifth successful project. So if the programmer chooses a subsequence 0 0 0 0 of the original sequence, it satisfies his requirement above: no number 0 appears after any number 1. The programmer's purpose is to display as many items as possible while meeting the above requirements. Please help him calculate the maximum number of items that can be displayed.

Enter description:

The first line of each group of samples is an integer n, 1<=n<=100, and the second line is a 01 sequence of n items, and each item is separated by a space.

Output description:

Output a positive integer representing the maximum number of items that can be displayed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325344851&siteId=291194637