QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#1691. 极地科考

统计

2019 年,EI 号极地科考团来到南极洲进行科学考察。与建造在地上的科考站不同,他们采用的是一种新式的科考车,其能源已经可以通过南极的磁场来发电进行供应。这种车可以任意长地伸缩,但是最短只能缩至 $k$(以下单位均默认为米)。该车的活动范围可以看做在一个数轴上移动,其车头不能小于 $0$,车尾不能大于 $n$。经过测量,$[i-1,i]$ 这段区间内的磁场可以提供的电量是 $a_i$。

由于车伸缩得越长,内部的设施所需的电量就越多,EI 现在只关心每截车厢可以供应的平均电量,也就是总共发电量除以科考车当前的长度。为了简化问题,车头位置、车尾位置和车长都应当是整数。若车停留在 $[l-1,r] (r - l + 1 \ge k)$ 这段位置,平均电量则等于

$$ \frac1{r-l+1}\sum_{i=l}^r a_i $$

EI 希望你能够合理地规划车的位置,使得平均电量最大,以保证他的实验能够顺利进行。

但是在你们停留的这 $m + 1$ 天里,由于地质作用的原因,每过新的一天会发现有一段位置的磁场强度会发生变化,也就是有一处 $a_i$ 会发生修改。

EI 忙着规划实验,所以请你帮忙算出每天最优的电量。EI 是个很严谨的人,所以你需要将这个平均值以有理数形式输出。

输入格式

第一行三个整数 $n, k, m$,表示科考车可移动范围,科考车最短长度,以及总共会发生 $m$ 次磁场强度变动。

接下来一行 $n$ 个整数,第 $i$ 个 $a_i$ 表示在该段位置磁场能提供的电量。

接下来 $m$ 行,每行两个整数 $p, x$,表示将 $p$ 位置记录的磁场能提供的电量修改为 $x$。

输出格式

共输出 $m+1$ 行,第一行输出最初的最优平均电量,之后第 $i$ 行输出经过第 $i-1$ 次消息更新后的最优平均电量。

具体的输出要求为:设输出的有理数为最简分数 $\frac xy$ 的形式,若 $\mathbf{y=1}$ 则请输出 $\mathbf{x}$,否则请输出 $\mathbf{x/y}$

样例一

input

5 3 2
2 8 2 6 6
2 6
1 6

output

11/2
5
26/5

explanation

最初,选取区间 $[1,5]$,于是平均电量为 $\frac14(a_2+a_3+a_4+a_5)=\frac{11}2$。

经过第一次修改后,数据变为 $(2, 6, 2, 6, 6)$,仍然选取区间 $[1,5]$。

经过第二次修改后,数据变为 $(6, 6, 2, 6, 6)$,选取区间 $[0, 5]$。

样例二

见下发文件。

限制与约定

对于 $100\%$ 的数据,保证 $1 \le n\le 10^5, 1\le k \le \min(n, 10), 0 \le m \le 10^5, 1\le a_i, x\le 10^4, 1\le p \le n$。

测试点编号$n$$m$$k$
$1$$=1$$=0$$=1$
$2$$\le 10$$\le 10$
$3$$\le 30$$\le 30$
$4$$\le 60$$\le 60$
$5$$\le 10^2$$\le 10^2$
$6$$\le 3\times 10^3$$\le 3\times 10^3$
$7$
$8$$\le 10^5$$\le 10^5$
$9$
$10$
$11$$\le 10^2$$=0$$\le10$
$12$$\le 3\times 10^3$
$13$$\le 10^5$
$14$
$15$$\le 3\times 10^3$$\le 3\times 10^3$
$16$$\le 4\times 10^4$$\le 4\times 10^4$$\le4$
$17$
$18$$\le 10^5$$\le 10^5$$\le10$
$19$
$20$

时间限制:$2\texttt{s}$

空间限制:$512\texttt{MB}$

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.