版本比较
题解:CF1901D Yet Another Monster Fight
正文
增加 6 行删除 6 行
1223456456789109101112131442 行未改动首先,当第一次选择 $i$ 号点时,$j$ 号点需要的能量为以下几种可能:1. $j=i$ 时,需要的能量为 $a_j$。 1. $j=i$ 时,需要的能量为 $a_j$。 $\therefore x\ge a_j$。 2. $j<i$ 时,明显最坏情况是将 $i$ 及右边全攻击完,再攻击 $j$,此时,按攻击顺序来,可得到 $j$ 是在第 $n-j+1$ 次被攻击的。 $\therefore x-(n-j+1)+1\ge a_j$。
2. $j<i$ 时,明显最坏情况是将 $i$ 及右边全攻击完,再攻击 $j$,此时,按攻击顺序来,可得到 $j$ 是在第 $n-j+1$ 次被攻击的。$\therefore x-(n-j+1)+1\ge a_j$。$\therefore x\ge a_j-j+n$。
3. $j>i$ 时,最坏情况为将 $i$ 及左边全攻击完,再攻击 $j$,此时,可得到 $j$ 是在第 $j$ 次被攻击的。 $\therefore x-j+1\ge a_j$。 3. $j>i$ 时,最坏情况为将 $i$ 及左边全攻击完,再攻击 $j$,此时,可得到 $j$ 是在第 $j$ 次被攻击的。$\therefore x-j+1\ge a_j$。$\therefore x\ge a_j+j-1$
综上,当第一次攻击 $i$ 时,最大攻击力为 $\max(\displaystyle\max_{j=1}^{i-1}\{a_j-j+n\},a_i,\displaystyle\max_{j=i+1}^n\{a_j+j-1\})$。
42 行未改动