P2085 Minimum Function Values
Description
There are $n$ functions, denoted $F_1, F_2, \dots, F_n$. Define $F_i(x) = A_i x^2 + B_i x + C_i$ for $x \in \mathbb{N}^*$. Given these $A_i$, $B_i$, and $C_i$, find the smallest $m$ values among all function values of all functions (if there are duplicates, output them multiple times).
Input Format
The first line contains two positive integers $n$ and $m$.
Each of the following $n$ lines contains three integers; on the $i$-th line they are $A_i$, $B_i$, and $C_i$.
Output Format
Output the first $m$ elements of the sorted sequence of all function values generated by the $n$ functions. Print these $m$ numbers on one line, separated by spaces.
Explanation/Hint
Constraints
For all test points, it is guaranteed that $1 \leq n, m \leq 10000$, $1 \leq A_i \leq 10$, $0 \leq B_i \leq 100$, $0 \leq C_i \leq 10^4$.
Translated by ChatGPT 5