2021 Alibaba School Recruitment Written Test Questions

Topic:
Xiao Ming and Xiao Qiang are playing a game, now there is a non-decreasing number sequence, and then follow the steps in sequence (Xiao Qiang starts first):
Everyone chooses a number in the current sequence and puts this number in the sequence for the first time The position and the numbers to the left are all deleted. When someone finishes the operation and the sequence is empty, that person wins. For example: the sequence at this time is 111222, if Xiaoqiang chooses 2, then the sequence obtained after deletion is 22. Assuming that Xiao Ming and Xiao Qiang are both big brothers, who can win the game in the end?

Input description: the
number of test cases in the first line.
For each group of data, the first line is an integer n, where n represents the number of digits in the sequence.
The next line of n integers, where a[i] represents the i-th integer.
Output description:
For each group of data.
If Xiaoqiang can win, output "xiaoqiang".
If Xiaoming wins, output "xiaoming"
input:

1
5
2 2 3 3 6

Output:

NIUNIU

Topic:
Xiaoqiang has an n-story collection cabinet with weights for the collections. The higher the weight, the more precious the collection. Xiaoqiang selected m collections, but not the best m.
Therefore, he has set a selection rule: each time he chooses, he can only choose the items at the two ends of a certain layer, and he can obtain the maximum weight sum under the premise of satisfying the above rules.
Input description: The
first line of two positive integers n and m, indicating the number of layers of the cabinet and the number of selections. The
next n lines, each line first enter a number x, indicating the number of items on this layer, and then enter x A positive integer, representing the weight c of each item. The input guarantees that there are more than m items that can be selected.
Output description:
output a line of integers to indicate the answer.
Input:

2 3 
2 3 2
4 1 4 1 5

Output:

10

Explanation: Xiaoqiang will select 2 items on the first floor and the fourth item on the second floor.

Guess you like

Origin blog.csdn.net/qq_35353824/article/details/107621237