Translation Notice
This article was machine-translated using DeepSeek-R1.
- Original Version: Authored in Chinese by myself
- Accuracy Advisory: Potential discrepancies may exist between translations
- Precedence: The Chinese text shall prevail in case of ambiguity
- Feedback: Technical suggestions regarding translation quality are welcomed
A - I Scream
Problem Statement
In Japan, there are four types of ice cream products:
- Products with at least 15% milk solids and 8% milk fat are called “ice cream”;
- Products with at least 10% milk solids and 3% milk fat that are not ice cream are called “ice milk”;
- Products with at least 3% milk solids that are neither ice cream nor ice milk are called “lacto ice”;
- Products that do not fall into any of the above categories are called “flavored ice”.
Here, milk solids consist of milk fat and milk solids-not-fat.
Given an ice cream product containing A% milk solids-not-fat and B% milk fat, determine its category.
Constraints:
- $0\le A,B\le 100$
- $0\le A+B\le 100$
Input Format
A B
Output Format
Output the category number:
- 1 for ice cream
- 2 for ice milk
- 3 for lacto ice
- 4 for flavored ice
Sample Cases
A | B | Output |
---|---|---|
10 | 8 | 1 |
1 | 2 | 3 |
0 | 0 | 4 |
Analysis
Calculate total milk solids by adding A and B, then check the conditions sequentially.
Code
|
|
B - Job Assignment
Problem Statement
A company has N employees. Employee i can complete Job A in A_i minutes and Job B in B_i minutes. Assign each job to one employee (possibly the same). The completion time t is:
- A_i + B_i if both jobs go to employee i
- max(A_i, B_j) if different employees take the jobs
Find the minimum possible t.
Constraints:
- $2 \le N \le 1000$
- $1 \le A_i, B_i \le 10^5$
Input Format
|
|
Output Format
Print the minimal t.
Sample Cases
Please refer to AtCoder.
Analysis
Brute-force all possible (i,j) pairs with O(N²) complexity. Optimizations exist but are more complex.
Code
|
|
C - Squared Error
Problem Statement
$$\sum_{i=2}^{N} \sum_{j=1}^{i-1} (A_i - A_j)^2$$Constraints:
- $2 \le N \le 3 \times 10^5$
- $|A_i| \le 200$
Input Format
|
|
Output Format
Print the computed sum.
Sample Cases
Sample Input 1
|
|
Sample Output 1
|
|
Sample Input 2
|
|
Sample Output 2
|
|
Analysis
$$\text{Result} = (N-1)\sum A_i^2 - 2\sum_{i=1}^N (S_i \cdot A_i)$$
where S_i is the sum of previous elements.
Code
|
|
D - Journey
Problem Statement
On a graph with N nodes and no edges initially, perform operations until the graph becomes connected:
- Randomly select a vertex (uniform probability).
- Add an edge between current and selected vertex, then move to it.
Compute the expected number of operations.
Constraints:
- $2 \le N \le 10^5$
Input Format
|
|
Output Format
Print the answer with absolute error ≤1e-6.
Sample Cases
N | Output |
---|---|
2 | 2 |
3 | 4.5 |
Analysis
$$\sum_{i=1}^{N-1} \frac{N}{i}$$Code
|
|
E - Mex Min
Problem Statement
Given sequence A of length N, compute the minimum mex over all length-M contiguous subarrays.
Constraints:
- $1 \le M \le N \le 1.5 \times 10^6$
- $0 \le A_i \le N$
Input Format
|
|
Output Format
Print the minimal mex.
Sample Cases
Please refer to AtCoder.
Analysis
Maintain a sliding window count and track zeros using a set for efficient mex calculation.
Code
|
|