| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 4 초 | 1024 MB | 32 | 17 | 11 | 57.895% |
You are an analyst, studying the relationship between advertisement budget spending (denoted by $x$) and sales (denoted by $y$) over the period of $n$ months. More specifically, for every month of time from 1 to n you have the value of spending $x_i$ and sales $y_i$.
To quantify the relationship you are using linear regression with regularisation, which means that you are modelling $y$ as $y=Kx+B,ドル where $K$ and $B$ are real numbers minimising the penalty function:
$p(K, B) = \sum \big( (K \cdot x_i + B - y_i)^2 \big) + \lambda \cdot (K^2 + B^2) $
(Note: this is the standard penalty function for L2 regularised linear regression.)
For the report requested by your manager, you need to make several predictions. More specifically, you have a list of prediction queries, each described by four numbers --- $L_j,ドル $R_j,ドル $\lambda_j$ and $X_j$. To process such a query you need to perform the following steps:
You are given the ads spending and sales data, and the prediction queries descriptions. You are to process the queries and output the predictions.
First line of the input file contains an integer number $n$ (2ドル \le n \le 10^6$) denoting the number of months in the period you are studying.
Each of the following $n$ lines describes one month and contains two non-negative real numbers $x_i$ and $y_i$ not exceeding 10. They denote the budget spending and sales in the corresponding month.
The following line contains an integer number $m$ (1ドル \le m \le 10^6$) denoting the number of predictions to be made. Each of the following $m$ lines contains four numbers: $L_j,ドル $R_j,ドル $lambda_j$ and $X_j$ (1ドル \le L_j < R_j \le n,ドル 0ドル \le \lambda_j, X_j \le 10$). First two of them are integers, the remaining are real.
For each prediction query output one real number on a separate line --- the predicted sales assuming the advertisement spending is $X_j$ and the linear model has been fitted on months from $L_j$ to $R_j$ using L2-regularisation with $\lambda_j$ regularisation coefficient. The output must be accurate to an absolute or relative error of at most 10ドル^{-6}$.
5 1 2 3 4 5 6 7 8 9 0 2 1 3 0 10 1 5 1 10
11 4.90566037735849125
3 1 1.0 2 2.1 3 2.8 3 1 2 0 1.5 2 3 0 2.5 1 3 0 1.5
1.55 2.45 1.516666666666667
ICPC > Regionals > Europe > Northwestern European Regional Contest > The UK & Ireland Programming Contest > UKIEPC 2024 B번