- Triple Entertainment
In the TikTok feed, there are n videos available for a user to watch, each with a specific entertainment score. The user will choose three videos in sequence to watch, with the option to rewatch a particular video twice or even thrice.
Specifically, the user will select three indices i, j, k such that 0 ≤ i ≤ j ≤ k < n, where i, j, k represent the indices of the videos chosen. The user can select videos in the following ways:
- Watch the same video three times (i.e., i = j = k).
- Watch one video twice and another video once (i.e., i = j < k or i < j = k).
- Watch three different videos (i.e., i < j < k).
Each video has an entertainment score represented as an array entertainment of integers. The user's total enjoyment for watching the selected videos is calculated as follows:
- The enjoyment from the first video is entertainment[i].
- The enjoyment from the second video is multiplied by a factor r, contributing r * entertainment[j].
- The enjoyment from the third video is multiplied by a factor r², contributing r² * entertainment[k].
Given the array entertainment and the integer r, your task is to determine the maximum possible entertainment score the user can achieve by optimally selecting indices i, j, and k.
Example
Suppose n = 4, entertainment = [-1, 1, -2, 3], and r = -2.
Choose i = 1, j = 2, and k = 3.
- TikTok Server Network Optimization
TikTok is growing, and the developers need more servers to keep up with all the new users. They have installed n servers across different locations, and each server is placed on a large grid. The i-th server is located at the point (x[i], y[i]) on this grid.
The cost of connecting two servers, i and j, is the smaller of the two differences:
- The difference between their x coordinates: |x[i] - x[j]|, or
- The difference between their y coordinates: |y[i] - y[j]|
Here, |a| means the absolute value of the number a (ignoring any negative signs).
Your task is to find the minimum cost to build a network where all the servers can communicate with each other, either directly or through other servers.
Example:
n = 3
x = [2, 4, 8]
y = [6, 10, 9]
To connect the servers, here's the strategy:
- Connect the first and second servers: The servers are at (2, 6) and (4, 10). The cost is calculated as min(|2 - 4|, |6 - 10|) = 2.
- Connect the second and third servers: The servers are at (4, 10) and (8, 9). The cost is min(|4 - 8|, |10 - 9|) = 1.
- Connect the first and third servers: The servers are at (2, 6) and (8, 9). The cost is min(|2 - 8|, |6 - 9|) = 3. However, we already have a cheaper way to connect them indirectly through the second server.
So, the optimal way is to connect the first and second servers for 2, and then the second and third servers for 1. Thus, the total minimum cost is 2 + 1 = 3.
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.