Meituan written test java 4.22 (topic)

1. Xiaomei wants a scholarship


Time limit: 3000MS
Memory limit: 589824KB
Title description: Xiaomei is a hardworking college student. Mei wants to get a scholarship. Xiaomei has taken a total of n courses, each course has a credit ai, and Xiaomei's grade in this course is bi. Xiaomei’s school’s evaluation of scholarships is very simple: as long as the average score of all courses is not lower than a given standard X, and no courses fail, you can apply for scholarships.
The average score refers to the average of the scores of all courses weighted according to the credits (ie), and a failing course means that the score of the course is lower than 60 points.
Now Xiaomei will ask you a total of several times, asking whether she can apply for a scholarship in each course situation.

enter description

The first line is a positive integer T, indicating the number of inquiries.
For each query: The first line contains two positive integers n, X , which represent the number of courses and the average score requirement.
In the second line, n positive integers a1, a2,..., an represent the credits of each course.
In the third line, n non-negative integers b1, b2,..., bn represent the grades of each class. Numbers are separated by spaces.
For all data, 1≤n≤1000, 1≤T≤10, 1≤ai≤10, 0≤bi≤100, 90≤X≤100

output description

For each query, output "Yes" or "No" (without quotes) to indicate whether you can or cannot apply for the scholarship.

sample input

2
4 97
2 2 2 2
94 97 100 100
4 93
10 6 7 9
59 93 100 95

sample output

Yes
No

hint

Example Explanation
For the first inquiry, the average score of Xiaomei can be calculated as (94 2+97 2+100 2+100 2)/(2+2+2+2)=97.75, which is greater than the requirement of 97 and has no failure , so you can apply.
For the second inquiry, Xiaomei had one subject below 60, failed the subject and could not apply.

2. Xiaomei needs to make a dice.


Time limit: 3000MS
Memory limit: 589824KB
Title description: Different from the general six-sided dice, Xiaomei needs a total of n sides of the dice, and the numbers on each side are also different from the general ones. The numbers on the n sides need to be a1, a2,...an. Of course, the dice is a positive n-hedron, and the only legal requirement is that the sum of all opposite sides needs to be equal, such as a six-sided dice with numbers 1, 2, 3, 4, 2, 3, then the above 1, 4 on the bottom, 2 on the front, 3 on the back, 2 on the left, and 3 on the right are legal solutions.
Because there are many options, Xiaomei doesn't care how to make such a dice. Xiaomei just wants to know whether she can make a legal dice. Of course, n is guaranteed to be even.

enter description

An integer T in the first line indicates the number of query data sets. For each group of queries:
the first line is a positive integer n, indicating the number of sides of the dice.
The next line contains n integers in each line, which are a1, a2,..., an.
Let N = the sum of n of all query data.
For all data, 1≤T≤100, 1≤N≤105, 1≤ai≤105, n is an even number.

output description

For each set of queries, output "YES" or "NO" (without quotes) to indicate whether the dice can be assembled.

sample input

2
6
1 2 3 4 2 3
6
1 2 4 5 6 7

sample output

YES
NO

3. Xiaomei is farming


Time limit: 3000MS
Memory limit: 589824KB
Title description: Xiaomei is playing a farming game recently. The purpose of this game is to earn as much money as possible. There are n kinds of crops in the game, and it takes ti days for the i-th crop to be harvested from planting to maturity. The buying price of seeds is ai, and the selling price of crops is bi (a Seeds will only produce one crop, and seeds can be purchased repeatedly). However, the total time in the game is m days, and it does not take time to plant, pick, and sell the seeds of the crops, and the crops are worthless before they mature.
Assuming that Xiaomei only has one piece of land (that is, only one crop can grow at a time), and the initial money is enough, Xiaomei wants to know how much she can earn at most.

enter description

The two integers n and m in the first line represent the number of crop types and the number of days. Each of the next three lines contains n integers,
representing
t1,...,tn,
a1,...,an,
b1,...,bn.
For all data, 1≤ti≤m≤2000, 1≤n≤100000, 0≤ ai≤bi≤10000

output description

Output an integer representing the most money Xiaomei can earn

sample input

3 12
3 4 7
9 3 2
11 6 11

sample output

12

hint

The most profitable plan is to plant a second crop first, and then a third crop. It takes 4+7=11 days and the money earned is 6-3+11-2=12. It can be proved that this is the most The best solution (of course, the third type first and then the second type will do).

4. Delete the 01 string


Time limit: 3000MS
Memory limit: 589824KB
Title description: Xiaomei gives you a 01 string of length n (a string containing only characters 0 and 1), you can delete a prefix and a suffix of this string (can be empty), That is to keep a continuous substring of the original string. After the operation, the cost of the entire string is the sum of the following two parts:
1. The number of deleted characters 1;
2. You need to minimize the number of characters 0 in the remaining substring The cost of the optimization operation and output it.

enter description

Enter only one line, a 01 string of length n.
For all data, 1≤n≤105

output description

The output is only one line, an integer, representing the minimum operation cost.

sample input

101110110

sample output

2

hint

Remove the first two characters and the last character at a cost of 1; the remaining string has a 0 at a cost of 1. So the sum of the costs is 2.

5. Xiaomei plays games


Time limit: 3000MS Memory limit: 589824KB Title description: Xiaomei is participating in a competition. A total of 2k people participated in this competition (including Xiaomei), numbered 1, 2,..., 2k, and everyone was in the same group at the beginning. The procedure of the competition is as follows: Assuming that there are n people in the current group (n is an even number), then the first n/2 people are divided into a new group, and the last n/2 people are divided into a new group, and then the two groups are respectively Competition, determine their respective winners, and then the winners of the two groups will compete, the winner will be the winner of the current group until the winner of the original group is determined. Of course a person's group winner must be himself. For example, if there are 4 people in the current group, numbered 1, 2, 3, 4, then 1, 2 will be divided into a group, 3, 4 will be divided into a group to compete separately, and then the winner of 1, 2 and 3 , The winners of the 4 will compete again to determine the winner of the entire group.
Since everyone has different abilities, Xiaomei predicted the winners of everyone's two-two competition, and now Xiaomei wants to know who the final winner is.

enter description

The first line is a positive integer k, indicating that the total number of people is 2k.
The next 2k lines contain 2k integers in line i.
Where vij=i or j means the winner of the competition between i and j.
For all data, 1≤k≤8, 1≤vij≤2k

output description

Output an integer representing the number of the final winner.

sample input

2
1 2 3 1
2 2 3 2
3 3 3 3
1 2 3 4

sample output

3

hint

sample explanation

First 1,2,3,4 group, 1,2 group, 3,4 group, 1,2 competition, the winner is 2, 3,4 group, the winner is 3, then 2,3 competition, The winner is 3, so the final winner is 3.

Guess you like

Origin blog.csdn.net/m0_56170277/article/details/130312259