Drop 2017 Campus Recruitment online programming Problem _ work

Source: Internet
Author: User
There are two programming questions in the drop down online written question. The first question is the general problem, the solution has many kinds, the second question has certain difficulty, the record is as follows: 1, the continuous most Yamato
Topic description

An array has n elements, and the largest and most contiguous array of children is obtained. For example: [ -1,2,1], and the largest contiguous array of children is [2,1], and the number is 3.


Input description

 

Enter two lines.

The first line, an integer n (1<=n<=100000), represents a total of n elements, a second act n, and each integer in the range of 32-bit int. separated by a space. Output description

 

All contiguous sub arrays and the largest values. Input example

 

3

-1 2 1 output examples

2
2. Restaurant
Topic description

A restaurant has n tables, each table has one parameter: A can accommodate the maximum number of guests, there are M group of customers, each group has two parameters: B number, C estimated consumption amount. In the case of not allowing the table, please implement an algorithm to select some of the guests, so that the total estimated consumption of the largest amount.

Input description

 

The input includes m+2 lines.

The first line consists of 2 integers n (1<=n<=50000), M (1<=m<=50000)

The second behavior n parameter a, the maximum number of people each table can accommodate, is separated by a space and is within the range of 32-bit int.

The next m line, two parameters B and c per line, representing the number of guests in the I group and the estimated consumption amount, separated by a space, in the range of 32-bit int. Output description

 

Outputs an integer that represents the maximum total estimated consumption amount. Input example

 

3 5

2 4 2

1 3

3 5

3 7

5 9

1 10 Output examples

20

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.